傳送附件郵件demo

2021-09-27 06:55:37 字數 1400 閱讀 1834

import smtplib

from email.mime.text import mimetext

from email.mime.multipart import mimemultipart

from email.mime.image import mimeimage

from email.header import header

def send_mail(file_new,receiver):

# f = open(file_new,"rb")

# mail_body = f.read()

# att = mimeimage(mail_body)

# att.add_header('content-disposition', 'attachment', filename='report.png')

# f.close()

# # 發件人

# username="[email protected]"

# password="aaaaaaaaaa"

# # 收件人

# receiver = receiver

# # 郵件內容

# # msg = mimetext(mail_body,'html','utf-8')

# msg = mimetext("hello yangyangyang, this is your email")

# # 附件內容

# msgroot = mimemultipart('related')

# msgroot['subject'] = header("自動化測試報告",'utf-8')

# msgroot.attach(msg)

# msgroot.attach(att)

# # smtp = smtplib.smtp()

# smtp.connect('smtp.exmail.qq.com') ##smtp.connect() 用於鏈結郵件伺服器

# smtp.login(username,password) ##smtp.login() 用於配置傳送郵箱的使用者名稱密碼

# for i in receiver:

# smtp.sendmail(username,i,msgroot.as_string()) ##smtp.sendmail() 配置傳送郵箱,接收郵箱,郵件傳送內容

# smtp.quit()

# # # send_mail("e:",["[email protected]","[email protected]"])

python 傳送郵件,附件郵件

1,傳送郵件 import smtplib from email.mime.text import mimetext msg from sunruirui1028 163.com 傳送方郵箱 passwd srui1028 填入傳送方郵箱的授權碼 msg to 1048786140 qq.com 收...

php傳送郵件附帶附件

define eol r n define smtp host smtp.sina.com.cn smtp伺服器 define smtp port 25 smtp伺服器端口 define smtp user smtp伺服器的使用者帳號 define smtp pass smtp伺服器的使用者密碼 d...

c 傳送郵件 附件

winform窗體 如下 using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.linq using ...