这是我用来通过 Python 发送带有附件的电子邮件的代码,但它不适用于 tumblr,基本上,脚本发送的电子邮件正常,但 tumblr 不将其识别为照片帖子,谁能请请让我知道如何解决它?太感谢了,
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
import smtplib
import os
user_name = 'username'
password = 'password'
msg = MIMEMultipart()
msg['Subject'] = 'photo post via email'
msg['From'] = 'from@gmail.com'
msg['To'] = 'to@tumblr.com'
file_path = os.path.join('A_smile_a_day_keeps_the_pain_and_the_doctor_away.jpg')
fp = open(file_path, 'rb')
img = MIMEImage(fp.read())
fp.close()
msg.attach(img)
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(user_name, password)
server.sendmail(msg['From'], msg['To'], msg.as_string())
server.quit()