我一直在try 使用MailerSend的PHPAPI来发送模板,但无法正确设置模板变量.:
代码为:
...
$mailersend = new MailerSend(['api_key' => $maSecretKey]);
$recipients = [
new Recipient('client_email@gmail.com', 'the email'),
];
$variables = [
new Variable('my_registered_email@mail.com', ['date' => date('Y-m-d'), 'order_number'=>250, 'delivery'=>"chosen"])
];
$tags = ['tag'];
$emailParams = (new EmailParams())
->setFrom('my_registered_email@mail.com')
->setFromName('Website')
->setRecipients($recipients)
->setSubject('Se registro un pago nuevo')
->setTemplateId($templateVenta)
->setVariables($variables);
//->setTags($tags);
$mailersend->email->send($emailParams);
结果:
[22-Jun-2023 07:38:51美国/芝加哥]php致命错误:未捕获MailerSend\Exceptions\MailerSendValidationException:变量.0邮箱字段不存在于.*.邮箱中.(还有1个错误)在/home4/distrib2/public_html/tt/correo/vendor/mailersend/mailersend/src/Helpers/HttpErrorHelper.php:27中