试图通过Python向Google发送电子邮件,电子邮件被拒绝 [英] Trying to send email to Google through in Python, email being denied

查看:280
本文介绍了试图通过Python向Google发送电子邮件,电子邮件被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我从GoDaddy收件箱中的邮件传递系统收到一封电子邮件,错误信息为: $ b


[返回代码550] sid:Xtpe1o00e3l0Tyx01 :: 5.7.1更多信息。

作为参考,该脚本如下所示:

  import smtplib 
server = smtplib.SMTP_SSL('smtpout.secureserver.net',465)

print(登录:)
server.login(username,password)

subject =这是一封测试邮件!
msg =示例电子邮件消息
text ='主题:%s\\\
\\\
%s'%(subject,msg)
fromaddr =fromemail
toaddr =toemail
print(正在发送邮件...)
server.sendmail(fromaddr,toaddr,text)
server.quit()

但我相信我的错误与代码无关,但是Google阻止了这封电子邮件。

解决方案

警告:通过不完整的数据进行猜测

您的电子邮件遭到拒绝为垃圾邮件。确保您的电子邮件符合RFC2822。引用标准



唯一需要的标题字段是起源日期字段,
是发件人地址字段。



在你的情况下,至少添加 From: To:到您的外发电子邮件:

  text ='发件人:%s \转到:%s\ nSubject:%s\\\
\%%s'%(fromaddr,toaddr,subject,msg)



<并确认smtplib自动添加日期:字段。


I'm getting a strange error when I send email through Python using SMTP.

I get an email from Mail Delivery System in my GoDaddy inbox with the error:

[Return Code 550] sid: Xtpe1o00e3l0Tyx01 :: 5.7.1 more information. ye4si18523263pbb.103 - gsmtp

For reference, the script looks like:

import smtplib
server = smtplib.SMTP_SSL('smtpout.secureserver.net', 465)

print("Logging in: ")
server.login("username", "password")

subject = "This is a test email!"
msg = "Sample email message"
text = 'Subject: %s\n\n%s' % (subject, msg)
fromaddr = "fromemail"
toaddr = "toemail"
print("Sending email...")
server.sendmail(fromaddr, toaddr, text)
server.quit()

But I believe my error has nothing to do with the code, but with Google blocking the email.

解决方案

Warning: Wild guess from incomplete data

Your email is being rejected as spam. Ensure your email is RFC2822-compliant. Quoting the standard:

The only required header fields are the origination date field and the originator address field(s).

In your case, add at least From: and To: to your outgoing email:

text = 'From: %s\nTo: %s\nSubject: %s\n\n%s' % (fromaddr, toaddr, subject, msg)

and confirm that smtplib automatically adds the Date: field.

这篇关于试图通过Python向Google发送电子邮件,电子邮件被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆