2013-06-25 91 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) 
相關問題