python - Sendgrid Python reply_to 电子邮件

标签 python class email sendgrid reply

我在使用 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_toinit() 中不被接受。在创建邮件对象后尝试设置 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/

相关文章:

C#:从程序安全发送错误报告

html - Django:如何发送带有嵌入图像的 HTML 电子邮件

python - 读取彩色数字图像是什么数字以进行控制台

python - 如何对数据框列上的多个短语应用正则表达式?

java - 初始化从另一个类调用的值时,预计 token ";"、 、 出现语法错误

java - 类的数组列表

python - 从视频中提取单帧

javascript - ReactJS 加载状态数据,优化

objective-c - cocoa /Objective-C : Access a (Boolean) variable in different Classes

Java正则表达式电子邮件替换所有空格和 "[at]"符号