python发送多人邮件_python 使用 smtp 无法向多人发邮件?

给单个人地址发就没问题,多人 list 就不行了。

这是报错内容

Error in functon : " send_text_email " ,

Error name is : " SMTPDataError " ,

Error type is : " " ,

Error Message is : " (554, 'DT:SPM 126 smtp2,DMmowECZeEbGLkNX_iNcAA--.205S2 1464020678,please see http://mail.163.com/help/help_spam_16.htm?ip=123.150.243.7&hostid=smtp2&time=1464020678') " ,

Error doc is : " The SMTP server didn't accept the data. " ,

msg 内容

From nobody Tue May 24 00:24:38 2016

Content-Type: text/plain; charset="utf-8"

MIME-Version: 1.0

Content-Transfer-Encoding: base64

From: =?utf-8?b?5rWL6K+V5py65Zmo5Lq6?= <[email protected]>

Subject: test

To: [email protected],[email protected]

aW5mbw==

主要代码

def send_text_email(self, title, message, message_type):

"""

发送文本邮件

没有返回值

函数内调用_format_address()

:param message_type:

:param message:

:param title:

"""

print 'send_text_email %s ' % title

msg = MIMEText(message, 'plain', 'utf-8')

msg['From'] = self._format_address(u'%s<%s>' % (self.mailName, self.sender))

msg['Subject'] = Header(title)

while 1:

try:

smtp = smtplib.SMTP()

# smtp.set_debuglevel(1)

print '开始尝试连接邮箱'

smtp.connect(self.smtp_server, self.smtp_server_port)

print '成功连接邮箱'

print '开始尝试登陆邮箱'

smtp.login(self.username, self.password)

print '成功登陆邮箱'

if message_type == "securityInfo":

print '开始发送事件邮件'

msg['To'] = ','.join(self.receiver)

print 'msg', msg

smtp.sendmail(self.sender, self.receiver, msg.as_string())

print '成功发送事件邮件'

except smtplib.SMTPAuthenticationError:

print '认证失败,邮箱连接可能出问题了'

self.count += 1

if self.count < 3:

time.sleep(10)

continue

else:

print '更换邮箱后重试...'

self.Mail_choose = not self.Mail_choose

self.mail_init()

self.count = 0

continue

except Exception as e:

error_text = exception_format(get_current_function_name(), e)

print error_text

time.sleep(10)

continue

else:

smtp.quit()

self.count = 0

break

求各位指教

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值