How to make SUBJECT Substitutions in Sendgrid Swift SmtpTransport?

非 Y 不嫁゛ 提交于 2019-12-13 04:39:53

问题


I am using Swift SmtpTransport as it seems to be the recommended way.

However the documentation I found dos not show how to achieve Subject Substitutions.

  • (This is what I am using) https://github.com/sendgrid/sendgrid-php-example/blob/master/smtp-php-example.php
  • https://github.com/sendgrid/sendgrid-php
  • http://swiftmailer.org/docs/sending.html#quick-reference-for-sending-a-message

回答1:


This was answered on Github, answering here too, for folks future reference.

To use the SMTPAPI to substitute for subjects, you'll need substitution tags in the subject of the email and then include the x-smtpapi header with substitution tags defined.

Using the SendGrid SMTPAPI Library:

<?php
...
$message->setSubject('[sendgrid-php-example] Owl named %yourname%');
$header           = new Smtpapi\Header();
$header->addSubstitution("%yourname%", array("Mr. Owl"))->
...


来源:https://stackoverflow.com/questions/22301042/how-to-make-subject-substitutions-in-sendgrid-swift-smtptransport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!