【发布时间】:2019-10-08 01:27:17
【问题描述】:
我在 A2 托管,但我使用 GSuite 来处理我的所有邮件。
当我从 Gmail 向 mail-tester.com 发送测试邮件时,我得到了非常好的评价。
但是,当我使用 PHP 脚本发送消息时:
$mail = new PHPMailer(true);
ob_start();
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $pickuploc . '@xxxx.com'; // SMTP username
$mail->Password = 'xxx';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom($pickuploc . '@xxx.com', 'xxx xxxx');
$mail->addAddress($email, $fname . " " . $lname); // Add a recipient
$mail->addBCC($pickuploc . '@xxx.com');
// Content
$mail->isHTML(true); // Set email format to HTML
include 'email-confirmed.html';
$mail->Subject = 'Your Reservation Has Been Confirmed!';
$mail->Body = ob_get_clean();
$mail->AltBody = 'Your reservation has been confirmed.';
$mail->send();
我从 mail-tester.com 收到一条错误消息,显示我的 DKIM 无效。
我认为这是因为我从国外服务器(不是 Google)发送,而我的 MX 记录指向 Google,但我确实需要这些电子邮件才能收到,我应该如何解决这个问题?
有没有办法在 PHP Mailer 中进行配置?谢谢。
【问题讨论】:
标签: php email phpmailer google-workspace dkim