-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from Integration-Automation/dev
Edit docs
- Loading branch information
Showing
9 changed files
with
72 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
讀取 Google 郵件使用 IMAP | ||
使用 IMAP 讀取 Google 郵件 | ||
---- | ||
|
||
.. code-block:: python | ||
from je_mail_thunder import IMAPWrapper | ||
from je_mail_thunder import IMAPWrapper, set_mail_thunder_os_environ | ||
# 設定 IMAP host | ||
# 設置 IMAP 主機 | ||
imap_host = 'imap.gmail.com' | ||
# 初始化 IMAPWrapper | ||
# 初始 IMAP 包裝類別 | ||
imap_wrapper = IMAPWrapper(host=imap_host) | ||
imap_wrapper.imap_later_init() | ||
# 選擇郵件箱 | ||
set_mail_thunder_os_environ( | ||
"test_user", # your user | ||
"test_password" # your password | ||
) | ||
imap_wrapper.later_init() | ||
# 選擇搜尋的信箱 (沒有帶參數是全部) | ||
imap_wrapper.select() | ||
# 取得郵件 list | ||
mail_list = imap_wrapper.imap_mail_content_list() | ||
# 輸出郵件 主旨 從哪個郵件地址寄送到哪個地址 郵件 BODY | ||
# 取得郵件列表 | ||
mail_list = imap_wrapper.mail_content_list() | ||
# 輸出基本資訊 | ||
for mail in mail_list: | ||
print(mail.get("SUBJECT")) | ||
print(mail.get("FROM")) | ||
print(mail.get("TO")) | ||
print(mail.get("BODY")) | ||
# 退出 | ||
imap_wrapper.imap_quit() | ||
# 離開 | ||
imap_wrapper.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
寄送郵件使用 Google 信箱 | ||
使用 Google 信箱寄送郵件 | ||
---- | ||
|
||
.. code-block:: python | ||
from je_mail_thunder import SMTPWrapper | ||
from je_mail_thunder import mail_thunder_content_data_dict | ||
# 初始化 SMTPWrapper | ||
smtp_wrapper = SMTPWrapper() | ||
smtp_wrapper.smtp_later_init() | ||
mail_thunder_content_data_dict.update({ | ||
"user": "test_user", # 你的使用者 | ||
"password": "test_password", # 你的密碼 (google 需使用應用程式密碼) | ||
}) | ||
user = mail_thunder_content_data_dict.get("user") | ||
# 讀取 html 檔案 | ||
with open("test.html", "r+") as file: | ||
html_string = file.read() | ||
# 建立訊息 | ||
message = smtp_wrapper.smtp_create_message_with_attach( | ||
html_string, | ||
{"Subject": "test_subject", "To": user, "From": user}, | ||
"test.html", use_html=True) | ||
# 傳送訊息 | ||
smtp_wrapper.try_to_login_with_env_or_content() | ||
message = smtp_wrapper.create_message("test", {"Subject": "test_subject", "To": user, "From": user}) | ||
smtp_wrapper.send_message(message) | ||
# 退出 | ||
smtp_wrapper.quit() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters