1.  首页
  2.  博客
  3. Django sending email via Gmail

Django sending email via Gmail


在 Django setting.py 配置

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'hi@gmail.com'
EMAIL_HOST_PASSWORD = '123456'
EMAIL_PORT = 587

发送邮件

from django.core.mail import EmailMessage
email = EmailMessage('Mail Test', 'This is a test', to=['edison7500@gmail.com'])
email.send()

评论 0