我已经在 PHP 中设置了一个脚本来使用 PHPMailer 发送电子邮件。使用以下内容: - 使用 TLS 通过我自己的域 SMTP 服务器发送;- 使用 DKIM/SPF 签名/验证消息;- “发件人”电子邮件地址在我发送邮件的域上,以及“回复”
不幸的是,该电子邮件被 Gmail 自动标记为垃圾邮件。我的域没有被列入黑名单(由 MXtoolbox.com 报告),并且在 SpamAssasin 上的得分为 1.49。
PHP代码如下:
<?php
require 'PHPMailerAutoload.php';
$adresaMail = "contact@hbooking.eu";
$mail = new PHPMailer();
$mail->Sender = $adresaMail;
$mail->From = $adresaMail;
$mail->FromName = "Hotel Booking";
$mail->AddReplyTo($adresaMail, "Hotel Booking"); //Reply-To Address
$mail->IsSMTP();
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $adresaMail; // SMTP username
$mail->Password = "Tele7abc$"; // SMTP password
$mail->SMTPSecure = 'tls'; // use TLS authentication
// $mail->SMTPSecure = "ssl"; // turn on SSL use
$mail->Host = "localhost";
$mail->Port = 25;
// $mail->SMTPDebug = 1; // Enables SMTP debug information (for testing, remove this line on production mode)
// 1 = errors and messages
// 2 = messages only
// $mail->ConfirmReadingTo = $adresaMail;
$mail->IsHTML(true); //turn on to send html email
//add image - begin
//$mail->AddEmbeddedImage('test.jpg', 'logoimg', 'test.jpg');
//add image - end
$mail->Subject = "Hotel booking webpage";
// use this if you want to use image
// $mail->Body = "Acest email a fost trimis folosind phpmailer - <img src=\"cid:logoimg\" />";
$Body = "<!DOCTYPE html>
<html lang='en' style='width: 100%; margin: 0'>
<head>
<meta charset='utf-8' />
<title></title>
</head>
<body style='font-size: 1em; width: 100%; margin: 0; background-color: white; font-family: 'Candara', 'Droid Sans', 'Roboto', 'Verdana', sans-serif'>
<table style='margin-top: 3%; width: 90%; max-width: 800px; margin-right: auto; margin-left: auto; border: 1px solid #c0c0c0; padding: 1rem; border-collapse: collapse'>
<tbody>
<tr>
<td style='background-color: #4169e1; font-size: 1.6rem; font-weight: 600; color: white; width: 10%; max-width: 80px; padding: 1rem'><span style='color: #ffda47'>H</span>B</td>
<td style='background-color: #4169e1; font-size: 1.6rem; font-weight: 600; color: white; padding: 1rem; text-align: right'><span style='color: #ffda47'>H</span>Booking.eu</td>
</tr>
<tr>
<td colspan='2' style='padding: 1rem; background-color: #f7f7f7'><p style='font-size: 1.25rem; font-weight: 600'>Signup confirmation</p>
<p>Thank you for choosing to be a <strong>HBooking.eu</strong> member!</p>
<p>Your subscription to our services has been confirmed.<br>
You can now log-in and <strong>start advertising your hotel nights</strong> to all our travel agents and tour operator members across Europe.</p>
<p>Please feel free to contact us for any queries you may have.</p>
<p>Yours truly,<br>The <strong>HBooking.eu</strong> team
</td>
</tr>
<tr><td colspan='2' style='background-color: #4169e1; color: white; text-align: center; padding: 1rem'>© HBooking.eu , 2017. This email has been sent automatically; please do not reply to it.</td></tr>
</tbody>
</table>
</body>
</html>";
$mail->Body = $Body;
$mail->AddAddress("bogpop68@gmail.com","Bogdan Popescu");
if($mail->Send()){
$mail->ClearAddresses();
echo "message sent";
}
else {echo "did not send";}
?>
请帮忙。谢谢大家。