python 实现非验证发送邮件

#!/bin/env python
#_*_ encoding:utf-8 _*_
import smtplib
import string
from email.mime.text import MIMEText
from email.header import Header
from email.mime.multipart import MIMEMultipart  
from email.utils import COMMASPACE,formatdate  

HOST = "server.com"
subject = 'hello'
TO = '[email protected]'
FROM='[email protected]'
text = 'hai'


msg = MIMEMultipart()   
msg['From'] = FROM
msg['Subject'] = subject     
msg['Date'] = formatdate(localtime=True)   
msg.attach(MIMEText(text))  
 
server = smtplib.SMTP()
server.connect(HOST,'25')

server.sendmail(FROM,TO,msg.as_string())
server.quit()

 

转载于:https://my.oschina.net/u/2313186/blog/787334

你可能感兴趣的:(python 实现非验证发送邮件)