def send_email(self):
try:
s = smtplib.SMTP(config.smtp_server, 587)
logging.info("hello world")
s.set_debuglevel(1)
s.ehlo()
logging.info("hello world2")
s.starttls()
logging.info("hello world3")
s.ehlo()
s.login(config.str_gmail_user, config.str_gmail_pwd)
s.sendmail(config.email_from,self.email_to , self.msg.as_string())
s.quit()
except Exception as e:
logging.info("erro")
logging.info('e: {}'.format(e))
raise e
我尝试使用python smtplib编写send_email函数,但它面临错误
日志如下:
INFO 2017-06-29 18:05:37,815 send_email.py:18]你好world2 发送:'STARTTLS \ r \ n'
回复:'220 2.0.0准备启动TLS \ r \ n'
回复:retcode(220);消息:2.0.0准备启动TLS
INFO 2017-06-29 18:05:37,978 send_email.py:26] erro
INFO 2017-06-29 18:05:37,978 send_email.py:27] e:[Errno 13]权限被拒绝
INFO 2017-06-29 18:05:37,979 user.py:91] e:[Errno 13]权限被拒绝
config.smtp_server =“smtp.gmail.com”
运行s.starttls()
时似乎失败了有关于此的任何想法?谢谢你的帮助