django使用EmailMultiAlternatives发送电子邮件

时间:2019-03-09 06:32:26

标签: python django email smtp

我需要使用django EmailMultiAlternatives发送电子邮件,经过长时间的研究,我找到了一种自定义主机,端口,用户和密码的方法,但是,当执行我的代码时,确实有一个奇怪的错误{{ 1}}

这是我的设置

'EmailBackend' object is not iterable

额外的变量

ACCOUNT_EMAIL = os.environ['ACCOUNT_EMAIL']
ACCOUNT_PASSWORD = os.environ['ACCOUNT_PASSWORD']
EMAIL_PROVIDER = 'krishna.hosting-mexico.net'
EMAIL_SERVER_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

这是我的功能

EMAIL = settings.ACCOUNT_EMAIL
PASSWORD = settings.ACCOUNT_PASSWORD
EMAIL_PROVIDER = settings.EMAIL_PROVIDER
EMAIL_SERVER_PORT = settings.EMAIL_SERVER_PORT
EMAIL_BACKEND = settings.EMAIL_BACKEND

connection = get_connection(host=EMAIL_PROVIDER, 
                                port=EMAIL_SERVER_PORT, 
                                username=EMAIL, 
                                password=PASSWORD, 
                                use_tls=True)

我尝试不指定def send_driver_welcome_email(user_email): from_email_address = EMAIL from_email_address_password = PASSWORD htmly = get_template('driver_welcome_email.html') html_content = htmly.render(None) msg = EmailMultiAlternatives('Bienvenido a TAXI 2.0', html_content, from_email_address, [user_email], connection) msg.attach_alternative(html_content, "text/html") msg.send() ,但仍然显示错误,这也是发送自定义“站点”作为电子邮件的距离,它包含一些图像和两个不同的样式表我没有找到其他办法,如果您有办法,那么您的建议将受到欢迎。

0 个答案:

没有答案