严重性:错误 --> 异常:"$email"必须是 SendGrid\Mail\From 的实例或有效的电子邮件地址



这是我的代码和问题严重性:错误-->例外:"$电子邮件";必须是SendGrid\Mail\From的实例或有效的电子邮件地址

require 'vendor/autoload.php';
$email = new SendGridMailMail();
$email->setFrom($this->ecomhut->getConfig('salesEmail'));
$email->setSubject($subject);

$email->addTo($data['email']);

//$email->addBcc($this->ecomhut->getConfig('supportEmail'));

$email->addBcc($this->ecomhut->getConfig('ForwarderEmail'));

$email->setReplyTo($this->ecomhut->getConfig('supportEmail'),NULL);

$email->addContent(
"text/html", $template
);

$sendgrid = new SendGrid($this->SENDGRID_API_KEY);

try {
$response = $sendgrid->send($email);

} catch (Exception $e) {

log_message('error', "Email Not Send form admin agianst ".$data['email']." n" .print_r($response));

return false;
}
return true;

Twilio SendGrid开发人员在此发布。

SendGridPHP库验证电子邮件地址是否设置为From和To地址。在这种情况下,投诉是发件人的电子邮件地址不是有效的电子邮件地址。

$email->setFrom($this->ecomhut->getConfig('salesEmail'));

在配置或数据库中存储电子邮件地址时,需要确保字符串是有效的电子邮件地址,包括删除前导或尾随空格。为了帮助实现这一点,您可以考虑使用trim函数来删除空白

$email->setFrom(trim($this->ecomhut->getConfig('salesEmail')));

这可以防止将来的错误影响电子邮件的发送。

相关内容

最新更新