2013-06-25 274 views
0

我有这个在我的setting.py文件:与Gmail的SMTP发送电子邮件

EMAIL_USE_TLS = True 
EMAIL_HOST = 'smtp.gmail.com' 
EMAIL_PORT = 587 
EMAIL_HOST_USER = '[email protected]' 
EMAIL_HOST_PASSWORD = 'Pass' 

我要发送电子邮件从一个模板发布的目的地:

from django.core.mail.message import EmailMessage 
destinations = request.POST['destinations'] #this return string with 2 emails ('[email protected]; [email protected]') 
EmailMessage(subject, core, to=[destinations]).send() 

它发送电子邮件只是第一封邮件而不是为了别人! 是否有任何操作使所有发布的电子邮件都能正常工作?

回答

1

传递一个列表to

import re 
# or you can use request.getlist('destination') 
# I do not know how you generate the two mail addresses 
destinations = re.split(r'[;\s]*', request.POST['destinations']) 
EmailMessage(subject, content, to=destinations) 
相关问题