简体   繁体   English

send_mail显然正在发送电子邮件,但收件箱中未显示任何电子邮件

[英]send_mail is clearly sending email but no email is showing up in inbox

I have these email settings in my settings.py 我的settings.py中有这些电子邮件settings.py

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'email@myemail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587

and am using this function to send email to recipients. 并正在使用此功能向收件人发送电子邮件。

def send_email(subject, body, recipients, agent_email, bcc=[], attachments=[]):
    recipient_list = []
    if isinstance(recipients, (str, unicode,)):
        recipient_list.append(recipients)
    else:
        recipient_list = recipients

    recipient_list = recipient_list + bcc

    send_mail(subject, body, settings.EMAIL_FROM, recipient_list)

while it looks quite clear when I go to the django-admin site that the email was indeed sent and no error messages show in the log files whatsoever, when I go to check the email that it was sent to, nothing shows in the inbox. 尽管当我去django-admin站点时看起来很清楚,电子邮件确实已发送,并且日志文件中均未显示任何错误消息,但是当我检查发送给它的电子邮件时,收件箱中没有任何显示。 I would expect to see the email there, especially given that it shows as sent in django-admin . 我希望在那里能看到该电子邮件,尤其是考虑到它显示为django-admin发送的电子邮件。 Have I misunderstood something about how email is sent from the system? 我是否误解了有关如何从系统发送电子邮件的信息?

EDIT 编辑

I also checked my spam folder and added 我还检查了我的垃圾邮件文件夹并添加了

EMAIL_FROM = 'email@myemail.com'

because I noticed it wasn't there before. 因为我注意到它以前不存在。 Same results, though. 结果相同。 Email appears sent according to django-admin but no email in my inbox. 电子邮件显示是根据django-admin发送的,但我的收件箱中没有电子邮件。

Try to add the following in settings.py 尝试在settings.py中添加以下内容

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'    
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM