#!/usr/bin/python
#coding=utf-8
import smtplib
from email.mime.text import mimetext
from email.header import header
mail_host = "smtp.163.com"
mail_user = "網易賬號@163.com"
mail_pass = "smtp服務密碼"
sender = '網易賬號@163.com'
receivers = ['qq號@qq.com']
#三個引數:第乙個為內容第二個是文字格式第三個是utf-8編碼
message = mimetext('你奈我何', 'plain', 'utf-8')
message['from'] = '網易賬號@163.com'
message['to'] = 'qq號@qq.com'
subject = "凱"
message['subject'] = header(subject, 'utf-8')
try:
smtpobj = smtplib.smtp()
smtpobj.connect(mail_host, 25) # 25 為 smtp 埠號
smtpobj.ehlo()
smtpobj.starttls()
smtpobj.login(mail_user,mail_pass)
# i = 1
# while(i < 10):
smtpobj.sendmail(sender, receivers, message.as_string())
# i = i + 1
print
"郵件傳送成功"
except smtplib.smtpexception,e:
print
"error: 無法傳送郵件"
print e;
iOS12系統應用傳送普通郵件構建郵件
當確定裝置支援郵件傳送功能後,開發者就可以實現該功能。根據是否包含附件,郵件可以分為普通郵件和附件郵件兩種。本節首先講解如何傳送普通郵件。實現過程如下 1.構建郵件 乙個郵件通常包含3個內容,分別為收件人 主題和郵件正文。構建郵件時,開發者需要依次設定這三部分。設定方法如下。1 收件人 郵件收件人分...
Python 指令碼傳送郵件
使用python完成郵件自動傳送 usr bin python coding utf 8 import smtplib from email.header import header from email.mime.text import mimetext class email sender ob...
python郵件傳送指令碼
複製 usr bin python coding utf 8 author dengyike date 2010 09 28 version 1.0 description auto sending email with attachment file import email import mim...