我正在使用苹果邮件应用程序和protonmail-我有桥应用程序。(MacOS and Windows install here;linux here。)
在激活桥接应用程序后,我尝试使用smtp库使用python发送电子邮件,但不起作用。以下是我试图运行的代码,但失败了:
import smtplib
server = smtplib.SMTP("127.0.0.1", portnumber)
server.login("mymail@protonmail.com", "my password")
server.sendmail(
"mymail@protonmail.com",
"receiver@protonmail.com",
"hello")
server.quit()
我收到的错误消息如下:
smtplib.SMTPDataError:(554,b‘’Error:事务失败,请将其归咎于天气:错误的MIME标题行: 00')
发布于 2019-05-28 02:34:39
这可能会有帮助..
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
port_number =1234
msg = MIMEMultipart()
msg['From'] = 'sender@protonmail.com'
msg['To'] = 'receiver@protonmail.com'
msg['Subject'] = 'My Test Mail '
message = 'This is the body of the mail'
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP('localhost',port_number)
mailserver.login("sender@protonmail.com", "mypassword")
mailserver.sendmail('sender@protonmail.com','receiver@protonmail.com',msg.as_string())
mailserver.quit()
发布于 2020-09-14 22:17:52
我是个新手,遇到了很大的麻烦……直到我做了以下小小的改变:
将from行更改为:
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
port_number =1234
msg = MIMEMultipart()
msg['From'] = 'sender@protonmail.com'
msg['To'] = 'receiver@protonmail.com'
msg['Subject'] = 'My Test Mail '
message = 'This is the body of the mail'
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP('localhost',port_number)
mailserver.login("sender@protonmail.com", "mypassword")
mailserver.sendmail('sender@protonmail.com','receiver@protonmail.com',msg.as_string())
mailserver.quit()
https://stackoverflow.com/questions/56330521
复制相似问题