我正试图为表单发送的邮件指定一个SendGrid类别。
SendGrid文档中提到了使用 X-SMTPAPI
它说它应该包含一个json对象在里面,并添加了 {'category': 'cat1'}
是应该做的伎俩。
这是我试过的方法。
由于WP Mail SMTP使用v3 API来发送邮件,你需要在请求体中添加你的自定义类别。
您可以通过以下代码来完成。
function wp_mail_smtp_add_cat( $body, $mailer ) {
$body['categories'] = array('testcat');
return $body;
}
add_filter( 'wp_mail_smtp_providers_mailer_get_body', 'wp_mail_smtp_add_cat', 10, 2 );
关于其他参数,请查看v3文档。https:/sendgrid.comdocsAPI_ReferenceWeb_API_v3Mailindex.html。