我正在使用Sendgrid API发送电子邮件,但我发送的每封电子邮件都没有Subjet
我的代码如下所示:
def send_notification(sendgrid_key, p_email):
message = Mail(
from_email=('my_email@mail.com'),
to_emails=(p_email),
subject='subject email',
)
message.template_id = 'XXXXXX'
try:
sg = SendGridAPIClient(sendgrid_key)
response = sg.send(message)
except Exception as e:
print(str(e))
尽管如此,我已经设置了subjet
,我仍然收到没有主题的电子邮件。此外,我的应用程序运行时没有任何错误
Twilio SendGrid开发者福音传道者
使用SendGrid的动态模板时,实际上是在模板中设置主题,而不是通过API。查看此屏幕截图,以查看在模板编辑器中设置主题的位置
如果要动态设置主题,可以在主题中添加模板字符串,并在发送电子邮件时通过动态模板变量进行设置。有关更多信息,请查看creating a dynamic email subject line with mustache templates上的这篇文章
相关问题 更多 >
编程相关推荐