2016-09-27 46 views
-1

我一直在閱讀所以試圖找到我的PHPMailer問題的答案。PHPMailer send()函數在活動服務器上崩潰但不是XAMPP

我正在使用最新的PHPMailer代碼,並在try和catch塊中有我的代碼。我在XAMPP託管站點和1 & 1.co.uk託管站點上使用相同的SMTP憑據。我也曾嘗試打印調試到一個文件,並知道腳本至於$mail->send()部分得到,但隨後我得到的回覆是一個頁面,指出:

的www.reasonstobejolly.com頁面無法正常工作

www.reasonstobejolly.com沒有發送任何數據。

沒有任何異常或拋出任何東西。任何人都可以解釋爲什麼這不起作用?

require '../../../PHPMailer-master/PHPMailerAutoload.php'; 

$mail = new PHPMailer(true); 
try { 
    $mail->SMTPDebug = 3; // Enable verbose debug output 

    $mail->isSMTP(); // Set mailer to use SMTP 
    $mail->Host = 'auth.smtp.1and1.co.uk'; // Specify main and backup SMTP servers 
    $mail->SMTPAuth = true;        // Enable SMTP authentication 
    $mail->Username = '##########';     // SMTP username 
    $mail->Password = '##########';  // SMTP password 
    $mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
    $mail->Port = 587;         // TCP port to connect to 

    $mail->setFrom('[email protected]', 'Orders at Reasons to be Jolly'); 
    $mail->AddAddress($email, $firstName." ".$lastName);  // Add a recipient 
    $mail->addReplyTo('[email protected]', 'Order Enquiry'); 

    $mail->isHTML(true);         // Set email format to HTML 
    $mail->Subject = "Your Order Has Been Received"; 
    $mail->Body = "Dear ".$firstName." ".$lastName."<br/>" 
    . "Your order has been received; it will be processed as soon as possible  and should be with you in the timeframe specified in our shipping guidelines.<br/> 

    "; 
    if (isset($randomPassword)) { 
     $mail->Body .= "<p>Username: $email</p><p>Password: $randomPassword</p>"; 
    } 


    $mail->Body .= "<p>Order Reference : $transactionId<br/> 
    Order Date  : ".date('d-m-Y H:i:s', strtotime($orderTime))."</p> 

    <p>BILL TO:<br/> 
    $shipToName <br/> 
    $shipToStreet<br/> 
    $shipToCity<br/> 
    $shipToState<br/> 
    $shipToZip<br/> 
    </p> 
    <p> 
    DELIVER TO:<br/> 
    $shipToName <br/> 
    $shipToStreet<br/> 
    $shipToCity<br/> 
    $shipToState<br/> 
    $shipToZip<br/> 
    </p> 

    <table> 
    <tr><td>Qty</td><td>Description</td><td>Price</td></tr>"; 
    $orderOverviewID = getOrderOverviewIDByPayPalReference($transactionId); 

    $orderItemsArray = getItemsByOrderOverviewID($orderOverviewID); 
    $postage = 0; 
    foreach ($orderItemsArray as $id => $order) { 

     $productEmail = getProductByProductID($order->productID); 
     $postageAmount = getPostageByPostageID($productEmail->postageID); 
     $mail->Body .= "<tr><td>".$order->itemQuantity."</td>" 
      . "<td>".$productEmail->productName."</td>" 
      . "<td>&pound;". (getDimensionByID(getColourByID($order->colourID)->dimensionID)->dimensionPrice) * $order->itemQuantity."</td></tr>"; 
     if ($postageAmount->postagePrice > $postage) { 
      $postage = $postageAmount->postagePrice; 
     } 
    } 
    // these are from create invoice. 

    $vat = $amt * 0.2; 
    $subtotal = $amt - $postage; 
    // TODO VAT and postage need to be calculated in the Paypal bit. 
    $mail->Body .= "<tr><td></td><td align='right'>Sub Total:</td>  <td>&pound;$subtotal</td></tr> 
    <tr><td></td><td align='right'>Standard Delivery:</td><td>&pound;$postage</td></tr> 
    <tr><td></td><td align='right'>(Including VAT @ 20%):</td><td>&pound;$vat</td></tr> 
    <tr><td></td><td align='right'>GRAND TOTAL:</td><td>&pound;$amt</td></tr> 
    </table> 


    If you have a query, or require further information, please contact Customer Service at: http://www.reasonstobejolly.com"; 

    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 
    $mail->send(); 
} catch (phpmailerException $e) { 
    echo $e->errorMessage(); //Pretty error messages from PHPMailer 
} catch (Exception $e) { 
    echo $e->getMessage(); //Boring error messages from anything else! 
} 
+0

我已經做了一些更多的調試追逐,它在保護功能smtpSend($ header,$ body) –

回答

0

打電話給1and1.co.uk後,他們支持的唯一郵件選項是mail()。他們告訴我PHPMailer不能在他們的服務器上工作。