我一直在阅读SO,试图找到我的PHPMailer问题的答案。
我正在使用最新的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('orders@reasonstobejolly.com', 'Orders at Reasons to be Jolly');
$mail->AddAddress($email, $firstName." ".$lastName); // Add a recipient
$mail->addReplyTo('enquiries@reasonstobejolly.com', '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>£". (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>£$subtotal</td></tr>
<tr><td></td><td align='right'>Standard Delivery:</td><td>£$postage</td></tr>
<tr><td></td><td align='right'>(Including VAT @ 20%):</td><td>£$vat</td></tr>
<tr><td></td><td align='right'>GRAND TOTAL:</td><td>£$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 :(得分:0)
打电话给1and1.co.uk后,他们支持的唯一邮件选项是mail()。他们告诉我,PHPMailer不会在他们的服务器上运行。