所以我使用PHPMailer向用户发送预订确认电子邮件。它已经工作了几个月,但突然之间,它就停止了工作。没有任何改变(至少我没有改变任何东西)。 PHPMailer文件仍然完好无损,我没有使用DNS / MX记录。这是发送电子邮件的脚本。它通过我的本地电子邮件地址向用户发送一个,向我发送一个。发给我的电子邮件发送成功,但客户端没有收到。当我尝试仅将其发送到客户端时,调试信息表明电子邮件已发送。它在引用收件人地址时一直说250 OK
(我猜这意味着它被接受)。它还显示整个消息,然后最终关闭连接。在脚本中,它也应该echo "true"
并且它会这样做。不过,我收到了无电子邮件。 BTW,我使用的是PHPMailer,具体而言只有下面脚本中包含的两个文件
以下是实际发送电子邮件的脚本。
<?php
include "connection.php";
session_start();
if(isset($_POST['problem_name'])){
$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$model_name = $_POST['model_name'];
$problem_name = $_POST['problem_name'];
$package_name = $_POST['package_name'];
$price = $_POST['price'];
$query = "INSERT INTO ext_orders (`date`, `name`, `address`, `phone`, `email`, `product`, `problem`, `package`, `addons`, `price`) VALUES ('".date("Y/m/d")."', '".$name."', '".$address."', '".$phone."', '".$email."', '".$model_name."', '".$problem_name."', '".$package_name."', 'No', ".intval($price).")";
if(mysqli_query($link, $query)){
$latest_id = mysqli_insert_id($link);
/***** COMPOSING OF EMAIL TO CUSTOMER AND A BCC TO MOBILECARE ******/
$message=
'
<h1>Mobilecare Urgent Repair Order Confirmation</h1> <br />
<h3> Personal Details </h3><br/>
<b>Name:</b> '.$name.'<br />
<b>Urgent Repair Address:</b> '.$address.'<br />
<b>Email:</b> '.$email.'<br />
<b>Phone Number:</b> '.$phone.'<br />
<h3> Product and order details </h3><br/>
<b>Model:</b> '.$model_name.'<br/>
<b>Type of Repair:</b> '.$problem_name.'<br/>
<b>Price:</b> '.$price.'<br/><br/>
If there are any problems with the information above, please reply to this email!<br/><br/>
Thank you,<br/>
Mobilecare.
';
include "../phpmailer/class.smtp.php";
include "../phpmailer/class.phpmailer.php";
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
$mail->SMTPDebug = true;
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->Host = localhost;
//Set who the message is to be sent from
$mail->setFrom('info@coherenthub.com', 'Mobilecare'); // info@mobilecare.ae
//Set an alternative reply-to address
//$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress(''.$email.'', ''.$name.'');
// $mail->AddBCC("info@coherenthub.com", "Mobilecare"); // info@mobilecare.ae
//Set the subject line
$mail->Subject = 'Mobilecare Order Confirmation';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->MsgHTML($message);
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
if ($mail->send()) {
echo "true";
}
}
else{
echo "fail";
}
}
?>
所有答案和评论都将不胜感激。
我有尝试过:
- 评论$mail->isSMTP()
- 播放MX唱片(尽管还原了所有更改)
- Redownloading PHPMailer(最新版本)
答案 0 :(得分:2)
您正在发送到localhost,这意味着您要提交到本地邮件服务器。这意味着无论使用isMail
还是isSMTP
,您都会获得相同的结果。听起来提交工作正常(您的250 OK
结果),但是从您的邮件服务器继续传递不是。这意味着您的PHPMailer代码没有任何问题,但您需要检查邮件服务器日志和配置。