使用SMTP从Python发送邮件
我正在使用以下方法使用SMTP从Python发送邮件。这是使用的正确方法,还是我想念的陷阱? from smtplib import SMTP import datetime debuglevel = 0 smtp = SMTP() smtp.set_debuglevel(debuglevel) smtp.connect(‘YOUR.MAIL.SERVER’, 26) smtp.login(‘USERNAME@DOMAIN’, ‘PASSWORD’) from_addr = “John Doe <john@doe.net>” to_addr = “foo@bar.com” subj = “hello” date = datetime.datetime.now().strftime( “%d/%m/%Y %H:%M” ) message_text = “Hello\nThis is a mail from your server\n\nBye\n” msg = “From: %s\nTo: %s\nSubject: %s\nDate: …