1. In setting.py define and set values for EMAIL_HOST, EMAIL_HOST_USER and EMAIL_HOST_PASSWORD.
2. In your views import django.core.mail.EmailMessage and SMTPConnection.
3. Create instance of EmailMessage e.g
email = EmailMessage('subject', 'message', 'from_email', list of recipient)
4. Send email by use send method e.g email.send()
5. SMTPConnection use for set connection when you want to send multiple messages in one connection if not create SMTPConnection it will create connection every call send() method e.g
connection = SMTPConnection()
email = EmailMessage('subject', 'message', 'from email', [list of recipient email], connection=connection)
1 comment:
Hi,
Thanks for the tutorial. I was searching for just this!
As of Django 0.97, the arguments of EmailMessage's __init__ seems to have changed:
def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, connection=None, attachments=None, headers=None)
Post a Comment