【发布时间】:2011-12-07 16:33:57
【问题描述】:
在我的 settings.py 中,我有这个值:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'user@gmail.com'
EMAIL_HOST_PASSWORD = 'pass'
EMAIL_USE_TLS = True
然后在我看来,我从我的模型中获得了一个电子邮件地址,例如:
#models.py
class Profile(models.Model):
name = models.CharField(...)
email_address = models.EmailField()
假设Profile模型中的email_address是sample@gmail.com
#views
def send_email(request,profile_id):
profile = Profile.objects.get(pk=profile_id)
email = profile.email_address
所以我什么时候发邮件,
send_mail('subject', 'content', email, ['example1@example.com'])
当电子邮件已经发送时,sender_email 仍然是 user@gmail.com。有人可以教我如何覆盖此电子邮件地址吗?谢谢。
【问题讨论】: