setting.py
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = 'xxxxx@gmail.com'
SERVER_EMAIL = 'xxxxx@gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'papercrib09@gmail.com'
EMAIL_HOST_PASSWORD = 'XXXXX'
views.py
print "before sending the mail"
send_mail(email_subject, email_body, 'xxx@gmail.com',
[yyy@gmail.com], fail_silently=False)
print "after sending the mail"
执行后我能看到该消息是从xxx@gmail.com发送到yyy@gmail.com
发送邮件之前:
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Account confirmation
From: xxx@gmail.com
To: yyy@gmail.com
Date: Sat, 22 Aug 2015 18:22:13 -0000
Message-ID: <20150822182213.5748.80357@SymMacToolkit-CPWKWBL7DTY3>
Hey user, thanks for signing up. To activate your account, click this link within 48 hours http://127.0.0.1:8000/accounts/confirm/1900aac9e91300ef2b35fdcc8cdc16305b2e0c18
发送邮件后:
没有
答案 0 :(得分:1)
您已在设置文件中添加了以下中间件
&#39; django.core.mail.backends.console.EmailBackend&#39;
这不会向Gmail客户端发送电子邮件。电子邮件正文将在您的应用程序运行的应用程序控制台上打印。尝试删除此行