我在使用 reply_to 时出错,这是我尝试过的...
这有效但没有 reply_to :
mail = Mail(
from_email = from_email,
to_emails = to_email,
subject = subject,
html_content = content)
response = sg.client.mail.send.post(request_body=mail.get())
我已经试过了:
mail = Mail(
reply_to = reply,
from_email = from_email,
to_emails = to_email,
subject = subject,
html_content = content)
response = sg.client.mail.send.post(request_body=mail.get())
这表明:
TypeError: init() got an unexpected keyword argument 'reply_to'
我也试过在 Mail() 之后添加这个:
mail.from_EmailMessage(reply_to=ReplyTo(Email(email=ANS_EMAIL,name='Mr X')))
抛出:
TypeError: object of type 'Email' has no len()
和:
mail.reply_to(ReplyTo(email=ANS_EMAIL,name='Mr X'))
抛出:
TypeError: 'NoneType' object is not callable
有什么帮助吗?
最佳答案
如您的错误所述,reply_to
在 init()
中不被接受。在创建邮件对象后尝试设置 reply_to
。
示例如下:
mail.reply_to = "reply-to@website.com"
or
message.reply_to = ReplyTo('reply-to@website.com', 'Reply Here')
有关如何自定义 sendgrid 电子邮件对象的更多详细信息 - Link
关于python - Sendgrid Python reply_to 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60951061/