發送郵件的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=[“你要發送的郵箱@qq.com”] msg=MIMEMultipart() msg[\\\’From\\\’]=Header(form_addr) msg[\\\’To\\\’]=Header(“你要發送的郵箱@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\\\’
如果,你對上面的內容還有疑問,推薦選擇三五互聯企業云郵箱!有專人協助您解答郵箱疑問。
三五互聯優質企業郵箱服務商,提供安全穩定,簡單易用,高性價比的企業郵箱。按需自由定制,不限空間,極速收發,能夠滿足用戶對企業郵箱的不同需求。多種反垃圾郵件算法,99.9%精準度,智能過濾,減少垃圾郵件干擾。支持小程序收發郵件,隨時隨地移動辦公。而且價格實惠,還可以免費試用,7×24小時專業團隊服務支持!
高性價比企業郵箱開通鏈接:http://m.shinetop.cn/services/mail/