2024-04-28 21:36:03 发布
网友
我在想。有没有办法在Python的默认SMTPlib上添加多个接收器?
比如(主题和内容已经设置好,smtp服务器gmail.):
python sendmail.py receiver1@gmail.com receiver2@gmail.com receiver3@gmail.com ...
谢谢
发布前测试!
import smtplib from email.mime.text import MIMEText s = smtplib.SMTP('smtp.uk.xensource.com') s.set_debuglevel(1) msg = MIMEText("""body""") sender = 'me@example.com' recipients = ['john.doe@example.com', 'john.smith@example.co.uk'] msg['Subject'] = "subject line" msg['From'] = sender msg['To'] = ", ".join(recipients) s.sendmail(msg.get('From'), recipients, msg.as_string())
从docs:
Send mail. The required arguments are an RFC 822 from-address string, a list of RFC 822 to-address strings (a bare string will be treated as a list with 1 address), and a message string.
发布前测试!
从docs:
相关问题 更多 >
编程相关推荐