-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5306de2
commit e276a39
Showing
1 changed file
with
18 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,27 +55,30 @@ | |
net.setInputMean((127.5, 127.5, 127.5)) | ||
net.setInputSwapRB(True) | ||
|
||
|
||
def mail(time): | ||
today=datetime.date.today() | ||
content='完成:'+str(time)+'個循環' | ||
|
||
msg = MIMEMultipart() # 使用多種格式所組成的內容 | ||
msg.attach(MIMEText(content, 'html', 'utf-8')) # 加入 HTML 內容 | ||
def mail(count, working_time, break_time): | ||
today = datetime.date.today() | ||
content = 'working time = ' + str(working_time) + ' minutes' + '<br>' | ||
content += 'break_time = ' + str(break_time) + ' minutes' + '<br>' | ||
content += '完成:' + str(count) + '個循環' | ||
msg = MIMEMultipart() # 使用多種格式所組成的內容 | ||
msg.attach(MIMEText(content, 'html', 'utf-8')) # 加入 HTML 內容 | ||
# 使用 python 內建的 open 方法開啟指定目錄下的檔案 | ||
with open('photo_0.jpg', 'rb') as file: | ||
img = file.read() | ||
attach_file = MIMEApplication(img, Name='photo_0.jpg') # 設定附加檔案圖片 | ||
msg.attach(attach_file) # 加入附加檔案圖片 | ||
attach_file = MIMEApplication(img, Name = 'photo_0.jpg') # 設定附加檔案圖片 | ||
msg.attach(attach_file) # 加入附加檔案圖片 | ||
|
||
msg['Subject']="%s 番茄鐘使用時間"%today | ||
msg['From']="tamtoooo" | ||
msg['To']='[email protected]' | ||
|
||
smtp = smtplib.SMTP('smtp.gmail.com', 587) | ||
msg['Subject'] = "%s 番茄鐘使用時間" % today | ||
msg['From'] = "tomato" | ||
msg['To'] = '[email protected]' | ||
|
||
# smtp = smtplib.SMTP('smtp.gmail.com', 587) | ||
smtp = smtplib.SMTP('smtp.gmail.com', 25) | ||
smtp.ehlo() | ||
smtp.starttls() | ||
smtp.login('[email protected]','ccwgwsrgdxqvcgtc')#要去google 帳戶>安全性>app 生成 | ||
# smtp.login() 的第二個參數 : 開啟應用程式密碼 | ||
# https://support.google.com/accounts/answer/185833 | ||
smtp.login('[email protected]', 'sender_account_key') | ||
status = smtp.send_message(msg) | ||
print(status) | ||
smtp.quit() | ||
|