我正在将Apple Mail应用程序与protonmail一起使用-我有网桥应用程序。我试图通过使用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')
答案 0 :(得分:3)
这可能有帮助。
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()
答案 1 :(得分:0)
我对此很陌生,遇到了一些重大麻烦。...直到我做了以下微小更改:
将行的内容更改为此:
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()