在我的settings.py
篇文章中,我有以下几点:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# Host for sending e-mail.
EMAIL_HOST = 'localhost'
# Port for sending e-mail.
EMAIL_PORT = 1025
# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
我的邮箱代码:
from django.core.mail import EmailMessage
email = EmailMessage('Hello', 'World', to=['user@gmail.com'])
email.send()
当然,如果我通过python -m smtpd -n -c DebuggingServer localhost:1025
设置调试服务器,我可以在我的终端中看到邮箱.
但是,我如何才能真正将邮箱发送到user@gmail.com而不是调试服务器呢?
读完你的答案后,让我直截了当地说:
您不能使用localhost(简单的ubuntu PC)来发送邮箱吗?
我想在Django 1.3中,
send_mail()
有点过时,取而代之的是EmailMessage.send()
?