如何在没有登录到Python的服务器的情况下发送电子邮件

问题描述 投票:0回答:1

我想在没有登录到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')”

python-3.x smtplib
1个回答
0
投票

下面的代码对我有用。首先,我通过网络团队打开/启用了端口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)
s.ehlo()
s.starttls()
server.sendmail(fromAddr, toAddr, text) 
server.quit()
© www.soinside.com 2019 - 2024. All rights reserved.