轻松发送电子邮件

mailwand的Python项目详细描述


MailWand

有天被未來的同事(應該啦?)問了
「怎麼發送嵌在email內的圖片啊? 不是附件喔!」

2020/09/10 - send inline image email -> send embed image email
2020/10/31 - send embed image email -> MailCrawler
2020/11/01 - MailCrawler -> MailSender
(MailSender被註冊了Orz...)
2020/11/01 - MailSender -> MailWand

名字好難想Rrrr...


Packages install

⚠️python version require >= 3.5⚠️

pip install mailwand

倘若安裝過程有問題請 pip install -r requirements.txt,應該都能解決。


使用方式 use

要先去設定 ./config/base.py 改設定喔!!!

直接搬 main.py 來講解

frommailwandimportMailWandif__name__=='__main__':# variable is 'Optional parameters'# ↓這裡用來取代html中 '{Sir}' 是要被取代成 'people_name'variable={'{Sir}':'people_name'}# ↓如果是這樣就是會找 ./config/base.py 中設定的檔案們MailWand_1=MailWand(variable)to_emails=['ooo@gmail.com','xxx@gm.lhu.edu.tw']# 要發送的對象們MailWand_1.send_to_mail(to_emails)# 群發(但彼此看不到)MailWand_1.close()# 關閉SMTP# variable is 'Optional parameters'# ↓這裡用來取代html中 '{Sir}' 是要被取代成 'people_name'variable2={'{Sir}':'people_name2'}# ↓也可以直接指定屬性,目前一共9個,可在 ./config/base.py 中找到MailWand_2=MailWand(variable2,header='這是第2種',# email標題images_path='./images2/',# 目前圖片只支援pnghtml_file='./template2.html'# html 檔案的位置)to_emails2=['ooo@gmail.com','xxx@gm.lhu.edu.tw']MailWand_2.send_to_multiple_recipients_mail(to_emails2)# 群發(收件人會看到彼此)MailWand_2.close()# 關閉SMTP

截圖

Imgur
Imgur


Application_password 獲取

ImgurImgurImgurImgurImgur

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java广播接收器未检测到按键事件   java不为特定列更改创建修订   java采用了更实用的方法   java桌面窗格HTML呈现   java处理internet连接丢失   java在调整JFrame的大小时,如何防止JTable的列调整大小?   如何用Java中的“Scanner.hasNext”完成程序   具有模块名称的java停止IntelliJ项目工具窗口?   执行已编译的Rails-Warbler JAR文件时发生java加载错误   java Spring数据redis存储库不支持集合查询?   每个客户端的java队列请求   获取Java中的JSON嵌套数组元素   java GWT,Vaadin ConcurrentModificationException   firebase存储中的java在保存照片之前,我需要发送两次照片   JavaSpringEleaf如何在容器外使用变量