To Send an Email

Create a new MailerMessage() object:

from mailqueue.models import MailerMessage

new_message = MailerMessage()
new_message.subject = "My Subject"
new_message.to_address = ""
new_message.cc_address = ""
new_message.bcc_address = ""
new_message.from_address = ""
new_message.content = "Mail content"
new_message.html_content = "<h1>Mail Content</h1>" = "Name of your App that is sending the email."

When save is called, Django will immediately try to send the email. Should it fail, it will be marked as unsent, and wait for the next time the job is called. Of course, the BCC address is optional, as well as html content.

Attaching Files

File attachments can be added to the e-mail with MailerMessage’s add_attachment method:

from mailqueue.models import MailerMessage
from django.core.files import File

message = MailerMessage(to_address="", from_address="")

photo_one = File(open("Poznan_square.jpg", "rb"))

# …you can add more than one file attachment
photo_two = File(open("Poznan_Malta-lake.jpg", "rb"))

Adding a Reply To header

You can add a reply to header to your emails be setting:

from mailqueue.models import MailerMessage

new_message = MailerMessage()
new_message.reply_to = ''

Sending to Multiple Recipients

To include more than one CC/BCC in your email, just separate the addresses with a comma:

message.cc_address = ",,"
message.bcc_address = ",,"

As of version 2.2.0 multiple recipients may be included in the to_address field as well:

message.to_address = ",,"

Using the Management Command

You can use the management command to send email:

python send_queued_messages --limit=20