所以我使用PHPMailer發送預訂確認電子郵件給用戶。它已經爲月工作,但突然間,它只是停止工作。沒有什麼改變(至少我沒有改變任何東西)。 PHPMailer文件仍然完好無損,我沒有使用DNS/MX記錄。這是發送電子郵件的腳本。它會向我的本地電子郵件地址發送一個給用戶和一個給我。指向我的電子郵件發送成功,但客戶端無法收到。當我嘗試將它發送給客戶端時,調試信息表明電子郵件已發送。在提及收件人地址時(我認爲它被接受),它總是說250 OK
。它也顯示了整個信息,最後它關閉了連接。在腳本中,它也應該是echo "true"
,它是這樣做的。不過,我收不到電子郵件。 順便說一句,我使用PHPMailer,具體而言,只有在下面的腳本包括在提到的兩個文件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('[email protected]', 'Mobilecare'); // [email protected]
//Set an alternative reply-to address
//$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress(''.$email.'', ''.$name.'');
// $mail->AddBCC("[email protected]", "Mobilecare"); // [email protected]
//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記錄播放(恢復所有變化,雖然) - 重新下載PHPMailer的(最新版本)
你能從命令行發送郵件嗎? – user2182349