任何人都请帮忙,我正在使用 sendgrid v3 api。但是我找不到任何方法可以将电子邮件发送给多个收件人。预先感谢。
import sendgrid
from sendgrid.helpers.mail import *
sg = sendgrid.SendGridAPIClient(apikey="SG.xxxxxxxx")
from_email = Email("FROM EMAIL ADDRESS")
to_email = Email("TO EMAIL ADDRESS")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)
我想将电子邮件发送给多个收件人。比如to_mail = “xxx@gmail.com, yyy@gmail.com”。
原文由 P113305A009D8M 发布,翻译遵循 CC BY-SA 4.0 许可协议
请注意,使用此处其他答案的代码,电子邮件的收件人将在 TO 字段中看到彼此的电子邮件地址。为了避免这种情况,必须为每个电子邮件地址使用一个单独的
Personalization
对象: