Home > programming > django send email

django send email

September 3rd, 2013

Mail is sent using the SMTP host and port specified in the EMAIL_HOST and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD settings, if set, are used to authenticate to the SMTP server, and the EMAIL_USE_TLS and EMAIL_USE_SSL settings control whether a secure connection is used.

add this code to setting.py as your email account

ALLOWED_HOSTS = []
EMAIL_USE_TLS = True
EMAIL_HOST = ‘smtp.example.com’
EMAIL_HOST_USER = ‘test@example.com’
EMAIL_HOST_PASSWORD = r’example’
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = ‘My Company ‘
SERVER_EMAIL = ‘webmas…@example.com’

views.py

from django.template.loader import render_to_string

def send_email(request):
    message = render_to_string(email.html)

    send_mail('Subject here', message, 'from@example.com',
    ['to@example.com'], fail_silently=False)

reference: https://docs.djangoproject.com/en/dev/topics/email/

Author: Richard Amodia Categories: programming Tags:
  1. July 14th, 2015 at 13:09 | #1

    The result – highly targeted and segmented campaigns that attract consumers and drive exponential revenues.
    A� Others can reach nearly 20 millions subscribers.

    But always keep in mind that it is a process that is worth the time and effort that you put into it.
    In addition to sending the email to the right people, your “offer” and
    content is key to assuring you get favorable results. It would not
    be likely that they will contact you without giving them anything.

  1. No trackbacks yet.