S
S
Sergey Nizhny Novgorod2016-02-22 12:41:29
Python
Sergey Nizhny Novgorod, 2016-02-22 12:41:29

Does anyone have the python 3+ mailing code?

Good afternoon.
I want to connect an e-mail newsletter to my django project, does anyone have the mailing code? It is desirable to be able to include html/css templates. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Voronkov, 2016-02-22
@DmitryVoronkov

And what does not suit " out of the box "?

L
legotin4, 2016-02-22
@legotin4

def hello(request):
  subject = u'Получите и распешитесь'
  message = u'Спасибо'
  from_email = settings.EMAIL_HOST_USER
  to_list = ['[email protected]']
  send_mail(subject, message, from_email, to_list, fail_silently=False)

  return HttpResponse("hello")

In settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #отправляет письма в консоль
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'pass'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '[email protected]'

See docks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question