发送多封电子邮件可以通过以下步骤完成:
import smtplib
from email.mime.text import MIMEText
def send_email(sender, receiver, subject, message):
# 配置邮件内容
msg = MIMEText(message)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = receiver
# 连接邮件服务器并发送邮件
with smtplib.SMTP('smtp.example.com', 587) as server:
server.login('your_username', 'your_password')
server.sendmail(sender, receiver, msg.as_string())
# 发送多封邮件
send_email('sender@example.com', 'receiver1@example.com', 'Subject 1', 'Message 1')
send_email('sender@example.com', 'receiver2@example.com', 'Subject 2', 'Message 2')
send_email('sender@example.com', 'receiver3@example.com', 'Subject 3', 'Message 3')
以上是发送多封电子邮件的基本步骤。在实际应用中,可以根据具体需求进行参数配置和错误处理。腾讯云提供了云邮件推送(Cloud Email)服务,可以用于发送电子邮件,具体详情请参考腾讯云云邮件推送产品介绍:https://cloud.tencent.com/product/ces。
领取专属 10元无门槛券
手把手带您无忧上云