Django发送邮件
setting中设置
EMAIL_USE_SSL = True
EMAIL_HOST = ‘smtp.qq.com’ # 如果是 163 改成 smtp.163.com
EMAIL_PORT = 465
EMAIL_HOST_USER = “xxx.xx.com” # 帐号
EMAIL_HOST_PASSWORD = “xxxxxx” # 授权码(****)
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
视图函数中定义
def my_send(req):
title = '来自自己的一封邮件'
message = '积善之家,必有余庆。积不善之家,必有余殃'
from_email = settings.DEFAULT_FROM_EMAIL
recieve = [
'firstemail@qq.com',#收件人邮箱地址
'othereamil@xx.com' # 其他收件人邮箱地址
]
send_mail(title,message,from_email,recieve)
return HttpResponse('邮件发送成功')