项目地址:https://github.com/kootenpv/yagmail
通过编写python脚本和计划任务,定时发送备份的附件到指定邮箱。
参考的脚本
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)