if len(sys.argv) <= 1: # 默认不带参数,发送不带附件的邮件 result = m.SendMail(subject, body, mail_tolist, cc_tolist) elif sys.argv[1] == 'attach': # 发送带附件的邮件 # os.system("dialog --title \"Pick Files\" --fselect /root/ 7 40 >> /tmp/sendmail.files") annex = input("Annex(Absolute path):") fileList = [] fileList.append(annex) # 检查文件是否存在 for f in fileList: if not os.path.isfile(f): # 文件不存在的处理方法 print("%s FILE NOT FOUND! PLEASE CHECK IT PATH" % f) result = m.SendMailAttach(mail_tolist, subject, body, fileList, cc_tolist) elif sys.argv[1] == 'html': # 发送html邮件 print("html") print(result) # to = "*****@*****.**" # cc = "" # subject = "hello" # # #邮件主体部分设置 # body = "" # print("Body:") # #body_head = "\t" + input() + "\n" # while True: