close

簡單的email client 使用python實現

 

#!/usr/bin/env python

# -*- coding: utf-8 -*-
from email.header import Header
from email.mime.text import MIMEText
from getpass import getpass
from smtplib import SMTP_SSL

# provide credentials if use yahoo
login = 'youremail.yahoo.com'
password = 'yourpassword'

# create message
msg = MIMEText('哈哈哈', 'plain', 'utf-8')
msg['Subject'] = Header('大部份測試', 'utf-8')
msg['From'] = login
msg['To'] = 'sendemail.xxx.com'

# send it if use yahoo
s = SMTP_SSL('smtp.mail.yahoo.com', timeout=10) #NOTE: no server cert. check
s.set_debuglevel(0)
try:

   s.login(login, password)

   s.sendmail(msg['From'], msg['To'], msg.as_string())
finally:
   s.quit()

arrow
arrow
    文章標籤
    python email
    全站熱搜
    創作者介紹
    創作者 太空梭創業日誌 的頭像
    太空梭創業日誌

    flysatellite的部落格

    太空梭創業日誌 發表在 痞客邦 留言(0) 人氣()