使用yagmail发送邮件

项目地址:https://github.com/kootenpv/yagmail

通过编写python脚本和计划任务,定时发送备份的附件到指定邮箱。

参考的脚本

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import yagmail
import os
file_path_array = ["backup_path1","backup_path2","backup_path3"]
backup_list = []
for file_path in file_path_array:
dirs = os.listdir(file_path)
bakup = os.path.join(file_path,dirs[1])
backup_list.append(bakup)
#print(backup_list)
yag = yagmail.SMTP(user = 'xxx@xxx.com', password = 'passwd', host = 'smtp.xxx.com')
yag.send(to = 'xxx@xxx.net', subject = 'Backup File', contents = backup_list)
import yagmail import os file_path_array = ["backup_path1","backup_path2","backup_path3"] backup_list = [] for file_path in file_path_array: dirs = os.listdir(file_path) bakup = os.path.join(file_path,dirs[1]) backup_list.append(bakup) #print(backup_list) yag = yagmail.SMTP(user = 'xxx@xxx.com', password = 'passwd', host = 'smtp.xxx.com') yag.send(to = 'xxx@xxx.net', subject = 'Backup File', contents = backup_list)
import yagmail
import os

file_path_array = ["backup_path1","backup_path2","backup_path3"]
backup_list = []
for file_path in file_path_array:
    dirs = os.listdir(file_path)
    bakup = os.path.join(file_path,dirs[1])
    backup_list.append(bakup)
    
#print(backup_list)


yag = yagmail.SMTP(user = 'xxx@xxx.com', password = 'passwd', host = 'smtp.xxx.com')
yag.send(to = 'xxx@xxx.net', subject = 'Backup File', contents = backup_list)
0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注