0
我有一些小問題。使用SMTP從Python發送附件郵件
我使用:
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
msg = MIMEMultipart()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Subject'] = 'simple email in python'
message = 'here is the email'
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP('smtp.gmail.com',587)
# identify ourselves to smtp gmail client
mailserver.ehlo()
# secure our email with tls encryption
mailserver.starttls()
# re-identify ourselves as an encrypted connection
mailserver.ehlo()
mailserver.login('[email protected]', 'mypassword')
mailserver.sendmail('[email protected]','[email protected]',msg.as_string())
mailserver.quit()
和寄託都還好 - 但我想添加一個TXT文件附件。你可以幫我嗎?
請不要使用所有的帽子。它就像是一樣。 – MattDMo 2014-09-26 17:55:03