I like to use Emailmultialternatives for sending with txt and html alternatives. If you want to use it a way to do it is:
from django.template.loader import render_to_string
from django.core.mail import EmailMultiAlternatives
message_html = render_to_string('seutemplate.html', dict_contexto)
message_txt = render_to_string('seutemplate.txt', dict_contexto)
subject = u"Um assunto"
from_email = u'[email protected]'
msg = EmailMultiAlternatives(subject, message_txt, from_email,
['[email protected]'])
msg = msg.attach_alternative(message, "text/html")
msg.send()
Or if you want something simpler, you can choose the default function of Django, the send_mail. Example:
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', '[email protected]',
['[email protected]'], fail_silently=False)
Remembering that in order for the upload to work, you will need to configure an upload backend, with the EMAIL_BACKEND variable from Settings. To test location you can use the backend console, where the message, after sending, will appear in the shell. To use the backend console assign the following value to the EMAIL_BACKEND:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'