發(fā)送郵件的Python文件
import smtplib,sys from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.header import Header def send_my_mail(subject,body,img): form_addr=”你的郵箱@163.com” my_fassword=\\\’你的郵箱密碼\\\’ to_addr=[“你要發(fā)送的郵箱@qq.com”] msg=MIMEMultipart() msg[\\\’From\\\’]=Header(form_addr) msg[\\\’To\\\’]=Header(“你要發(fā)送的郵箱@qq.com”) msg[\\\’Subject\\\’]=Header(subject,”utf-8″) body=MIMEText(body,\\\’plain\\\’,\\\’utf-8\\\’) msg.attach(body) try: att1=MIMEText(open(img,\\\’rb\\\’).read(),\\\’base64\\\’,\\\’utf-8\\\’) except Exception as e: return \\\’file not found\\\’ att1[\\\’Content-Type\\\’]=\\\’application/octet-stream\\\’ att1[\\\’Content-Disposition\\\’]=\\\’attachment;filename=%s\\\’%img msg.attach(att1) try: smtpobj=smtplib.SMTP() smtpobj.connect(\\\’smtp.163.com\\\’) smtpobj.login(form_addr,my_fassword) smtpobj.sendmail(form_addr,to_addr,msg.as_string()) # print(\\\’succeed\\\’) return \\\’succeed\\\’ except Exception as e: print(str(e)) return \\\’failure\\\’
如果,你對(duì)上面的內(nèi)容還有疑問(wèn),推薦選擇西部數(shù)碼企業(yè)云郵箱!有專人協(xié)助您解答郵箱疑問(wèn)。
西部數(shù)碼優(yōu)質(zhì)企業(yè)郵箱服務(wù)商,提供安全穩(wěn)定,簡(jiǎn)單易用,高性價(jià)比的企業(yè)郵箱。按需自由定制,不限空間,極速收發(fā),能夠滿足用戶對(duì)企業(yè)郵箱的不同需求。多種反垃圾郵件算法,99.9%精準(zhǔn)度,智能過(guò)濾,減少垃圾郵件干擾。支持小程序收發(fā)郵件,隨時(shí)隨地移動(dòng)辦公。而且價(jià)格實(shí)惠,還可以免費(fèi)試用,7×24小時(shí)專業(yè)團(tuán)隊(duì)服務(wù)支持!
高性價(jià)比企業(yè)郵箱開通鏈接:http://bingfeng168.cn/services/mail/