0
我正在处理联系表单以接收来自用户的电子邮件。我使用的是EmailMessage(django 1.3)。问题是,我能够收到电子邮件,但'from'或'sender'显示email_host_user电子邮件,而不是用户的电子邮件。EmailMessage'发送者'问题
因此,如果用户的电子邮件地址[email protected],当我收到的电子邮件
from: [email protected]
subject: some subject
to: [email protected]
,而不是
from: [email protected]
subject: some subject
to: [email protected]
继承人的一部分设定
EMAIL_HOST = 'smtp.googlemail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_HOST_USER = '[email protected]'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
REVIEW_MODERATOR ='[email protected]'
#heres part of the helpers.py
def run(self):
html = get_template(self.kwargs['template'])
html_content = html.render(Context(self.kwargs['context']))
msg = EmailMessage(
self.kwargs['subject'],
html_content,
self.kwargs['sender'],
[self.kwargs['email']],
bcc=[a[1] for a in settings.ADMINS])
msg.content_subtype = "html" # Main content is now text/html
try:
path = self.kwargs['file_path']
except KeyError:
pass
else:
msg.attach_file(path)
msg.send()
#heres part of the contact view
if contact_form.is_valid():
cdata = contact_form.cleaned_data
c={'name':cdata['name'], 'email':cdata['email'],'message':cdata['message']}
EmailThread(**{
'email':settings.REVIEW_MODERATOR,
'sender':cdata['email'],
'subject':email_subject,
'context':c,
'template':template
}).start()
嘿感谢信息真正感谢它yuji。 – user1544778 2012-08-17 04:05:33