我想发送电子邮件而不登录到Python中的服务器。我正在使用Python 3.6。我尝试了一些代码,但收到一个错误。这是我的代码:
import smtplib
smtpServer='smtp.yourdomain.com'
fromAddr='[email protected]'
toAddr='[email protected]'
text= "This is a test of sending email from within Python."
server = smtplib.SMTP(smtpServer)
server.set_debuglevel(1)
server.sendmail(fromAddr, toAddr, text)
server.quit()
我希望发送该邮件时无需询问用户ID和密码,但会收到错误消息:
“ smtplib.SMTPSenderRefused:(530,b'5.7.1客户端未通过身份验证','from @ Address.com')”
下面的代码为我工作。首先,我通过网络团队打开/启用了端口25,并在程序中使用了它。
import smtplib
smtpServer='smtp.yourdomain.com'
fromAddr='[email protected]'
toAddr='[email protected]'
text= "This is a test of sending email from within Python."
server = smtplib.SMTP(smtpServer,25)
server.ehlo()
server.starttls()
server.sendmail(fromAddr, toAddr, text)
server.quit()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句