相关疑难解决方法(0)

使用python同时向多个CC和多个TO收件人发送电子邮件

分别尝试了多个 to 和多个 cc,效果很好,但是当我尝试两者时,出现错误:

文件

“path\Continuum\anaconda2\envs\mypython\lib\smtplib.py”,第 870 行,在 sendmail senderrs[each] = (code, resp) TypeError: unhashable type: 'list'"

代码:

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication

strFrom = 'fasdf@dfs.com'

cc='abc.xyz@dfa.com, sdf.xciv@lfk.com'

to='sadf@sdfa.com,123.lfadf@fa.com'

msg = MIMEMultipart('related')
msg['Subject'] = 'Subject'
msg['From'] = strFrom
msg['To'] =to
msg['Cc']=cc

#msg['Bcc']= strBcc

msg.preamble = 'This is a multi-part message in MIME format.'


msgAlternative = MIMEMultipart('alternative')
msg.attach(msgAlternative)

msgText = MIMEText('This is the alternative plain text message.')
msgAlternative.attach(msgText)


msgText = …
Run Code Online (Sandbox Code Playgroud)

python sendmail

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

sendmail ×1