python模塊-發送郵件

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author:Sun
# make_time:2018/8/2
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr


def sendmail_2018():
    msg = MIMEText('python', 'plain', 'utf-8')  # 郵件內容、類型默認:plain、默認字符集
    msg['From'] = formataddr(['python學院', 'xius2222un@163.com'])  # 發送方
    msg['To'] = formataddr(['python', '3335@qq.com'])  # 接收方
    msg['Subject'] = 'python開發面試邀請'  # 主題
    server = smtplib.SMTP('smtp.163.com', 25)  # 郵件服務器
    server.login('郵箱', '密碼')  # 登錄
    server.sendmail('xxx@163.com', ['222@qq.com', '333@qq.com', ], msg.as_string())
    server.quit()
相關文章
相關標籤/搜索