Skip to main content

easy to send email

Project description

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 來講解

from mailwand import MailWand


if __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/',  # 目前圖片只支援png
        html_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 獲取

Imgur Imgur Imgur Imgur Imgur

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mailwand-1.0.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distributions

mailwand-1.0.0-py3.8.egg (7.7 kB view hashes)

Uploaded Source

mailwand-1.0.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page