T
T
Takumi2018-12-01 06:44:50
Django
Takumi, 2018-12-01 06:44:50

How to send email via SMTP in Django?

I'm using Django==2.1.3.
Set up the project to send emails via smtp

EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_HOST = 'smtp.mail.ru'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'my_password'

In order for this to work, set django-smtp-ssl==1.0.
Then send like this
send_mail(
            'Тема письма важная',
            'Данное сообщение отправленно потому что я проверяю как работает отправка письем из джанги. ЧТобы прикрутить ее для своего проекта',
            '[email protected]',
            ['[email protected]'],
            fail_silently=False,
        )

send_mail returns 1, which judging by the dock means that the email was successfully sent.
I look at the mail to which I sent the letter. No letter.
I thought about things in smtp.mail.ru and tried to send via Yandex. The result is the same.
Googling led me to a bunch of identical configuration questions and I seem to have done everything right, but the letter does not go away.
Tell me what I'm doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-12-08
@pyHammer

You probably have hosting) at least minimal. Create a mailbox there and fill in the necessary parameters in the documentation . Here it works not beget.ru

EMAIL_HOST = "smtp.beget.com"
EMAIL_HOST_USER = "[email protected]"
EMAIL_HOST_PASSWORD = "&*R5mVWt"
EMAIL_PORT = 465
EMAIL_USE_SSL = True
SERVER_EMAIL = "[email protected]"
DEFAULT_FROM_EMAIL = "[email protected]"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question