使用SMTP和Gmail在Django上发送电子邮件 [英] Sending emails on Django using SMTP and Gmail

查看:90
本文介绍了使用SMTP和Gmail在Django上发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用gmail和smtp时遇到以下问题,我允许访问我的gmail帐户中不安全的应用,并且能够在本地计算机上发送电子邮件,但是当我尝试在托管的远程服务器上发送电子邮件时我的应用程序我不断收到SMTPAuthenticationError.我不确定我还需要做什么才能使其在本地和远程服务器上都能正常工作.有人有什么想法吗?

I have the following problem with gmail and smtp, i allowed access to less secure apps on my gmail account and i'm able to send emails on my local computer, however when i try to send emails on the remote server that's hosting my application i keep getting SMTPAuthenticationError. I'm not sure what else do i need to do in order for this to work both locally and on the remote server. Anybody have any ideas?

我正在使用Django 1.11.15和Python 2.7.

I'm using Django 1.11.15 and Python 2.7.

这些是我在应用程序中拥有的设置:

These are the settings i have on my application:

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"

EMAIL_HOST = "smtp.gmail.com"

EMAIL_USE_TLS = True

EMAIL_PORT = 587

EMAIL_HOST_USER = "myemail@gmail.com"

EMAIL_HOST_PASSWORD = "mypassword"

推荐答案

密码是您的gmail的登录密码?访问 https://myaccount.google.com/security ,在左侧导航面板中,点击安全性.在登录Google面板中,点击应用密码,以获取密码.它对我有用.

The password is your gmail's login password? Visit https://myaccount.google.com/security, On the left navigation panel, click Security. In Signing in to Google panel, click App passwords, to get a password. It work for me.

如果它不起作用,请检查 Django SMTPAuthenticationError .

If it not work, check Django SMTPAuthenticationError.

这篇关于使用SMTP和Gmail在Django上发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆