1 回答
TA贡献1770条经验 获得超3个赞
为了弄清楚这一点,我从 Gmail 发送了一封电子邮件,然后单击已发送邮件旁边的三个点,然后单击“显示原件”,这会显示 Gmail 服务器传送的完整数据包。然后我只是将这些字段添加到我的消息中:
import smtplib
import email.mime.multipart
# Establish a secure session with gmail's outgoing SMTP server using your gmail account
server = smtplib.SMTP('smtp.gmail.com', 587)
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.login('me@gmail.com', pw)
msg = '\r\n'.join([
'MIME-Version: 1.0',
'Date: Fri, 22 Feb 2019 11:29:27 -0500',
'Message-ID: <CAKyky413ikdYD4-Oq_H_FPF-g__weSFehQNLVuspotupWhJaLA@mail.gmail.com>',
'Subject: wow on what',
'From: Ludwig Wittgenstein <me@gmail.com>',
'To: 5551234567@tmomail.net',
'Content-Type: multipart/alternative; boundary="0000000000003c664305827e1862"',
'',
'--0000000000003c664305827e1862',
'Content-Type: text/plain; charset="UTF-8"',
'',
'weeeee',
'',
'--0000000000003c664305827e1862',
'Content-Type: text/html; charset="UTF-8"',
'Content-Transfer-Encoding: quoted-printable',
'',
'<div dir=3D"ltr">here=C2=A0</div>',
''
'--0000000000003c664305827e1862--'
])
# sendmail(from, to, msg)
server.sendmail('me@gmail.com', '5551234567@tmomail.net', msg)
添加回答
举报