Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

2007-08-23

How to send email with Django

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)