【发布时间】:2015-05-05 08:02:40
【问题描述】:
我尝试使用 php 发送邮件,但没有收到任何邮件。实际上,我想在支付网关处理之后处理发送邮件功能。 这是我的代码:
$order_id = $_REQUEST['Order_Id'];
$AuthDesc = 'Y'; // $_REQUEST['AuthDesc'];
$Checksum = $_REQUEST['Checksum'];
$price = $_REQUEST['Amount'];
网关回复“Y”、“N”和“B”。让我们把它硬编码为'Y'进行测试。
if($AuthDesc == 'Y'){
$payStatus='SUC';
$updateSQL="UPDATE `tbl_cc_payment` SET `checksum`='".$Checksum."', `gateway_status`='1', `customer_status`='1' WHERE `order_id`='".$order_id."'";
$updateRs=mysql_query($updateSQL);
//Send mail:
if($updateRs){
$findmailidsql=mysql_fetch_array(mysql_query("SELECT * FROM `tbl_cc_payment` WHERE `order_id`='".$order_id."'"));
$cust_mail_id=$findmailidsql['cust_email'];
$txn_date=date('Y-m-d', strtotime($findmailidsql['txn_date']));
$to = $cust_mail_id;
$subject = 'Anantonline order confirmation | Transaction ID : '.$order_id;
$headers = "From: Pecon Sale Team <sales@pecon.co.in>" . "\r\n";
$headers .= "Reply-To: Pecon Sale Team <sales@pecon.co.in>" . "\r\n";
$headers .= "CC: transaction@pecon.co.in\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html>';
$message = '<head><title>Order Confirmation</title></head>';
$message .= '<body>';
$message .= '<h3>Hello, World!</h3>';
$message .= '</table>';
$message .= '<tr><td colspan="3" align="left">Dear'.$findmailidsql['billing_cust_name'].',</td></tr>';
$message .= '<tr><td colspan="3" align="left">Thank you for signing up with Anant Online.</td></tr>';
$message .= '<tr><td colspan="3" align="left">This is an acknowledgement receipt of your subscription for '.ucwords($findmailidsql['suprt_plan']).' with Transaction/Order ID '.$findmailidsql['order_id'].' dated '.$findmailidsql['txn_date'].'</td></tr>';
$message .= '<tr><td><strong>The details are shown below:</strong></td></tr>';
$message .= '<tr><td>Customer Name</td><td>:</td><td>'.$findmailidsql['billing_cust_name'].'</td></tr>';
$message .= '<tr><td>Plan Subscribed</td><td>:</td><td>'.$findmailidsql['suprt_plan'].'</td></tr>';
$message .= '<tr><td>Email Address</td><td>:</td><td>'.$findmailidsql['cust_email'].'</td></tr>';
$message .= '<tr><td>Customer Id</td><td>:</td><td>'.$findmailidsql['id'].'</td></tr>';
$message .= '<tr><td>Amount debited</td><td>:</td><td>'.$findmailidsql['amount'].'</td></tr>';
$message .= '<tr><td>Date of Purchase</td><td>:</td><td>'.$txn_date.'</td></tr>';
$message .= '<tr><td>Plan Start Date</td><td>:</td><td>'.$txn_date.'</td></tr>';
$message .= '<tr><td>Plan Expiry Date</td><td>:</td><td>'.$txn_date.'</td></tr>';
$message .= '<tr><td colspan="3" align="left">Please feel free to contact our help desk for further information.</td></tr>';
$message .= '<tr><td colspan="3" align="left">We thank you for choosing Anant Online as your solution provider and look forward to serve you through our hassle free , state-of-art remote support.</td></tr>';
$message .= '<tr><td colspan="3" align="left">For any further assistance you can log on to http://www.anantonline.com or dial our Helpdesk numbers or e-mail us at support@anantonline.com</td></tr>';
$message .= '<tr><td colspan="3" align="left">Please click on the links to read our <a href="http://buy.anantonline.com/terms.php">Terms and Conditions</a> and <a href="http://buy.anantonline.com/refundpolicy.php">Refund Policy</a>.</td></tr>';
$message .= '<tr><td colspan="3" align="left">With Regards, <br><strong>Anantonline Sales Team</strong></td></tr>';
$message .= '</table>';
$message .= '</body>';
$message .= '</html>';
mail($to, $subject, $message, $headers);
}
}elseif($AuthDesc == 'N'){
$payStatus='DEC';
}elseif($AuthDesc == 'B'){
$payStatus='BAT';
}else{
$payStatus='UNK';
}
header('location:payment-result.php?txn='.$order_id.'&status='.$payStatus);
请任何人给我一个解决方案来解决这个问题。谢谢你。
【问题讨论】:
-
您设置了 SMTP 吗?
-
将错误报告添加到您的打开 PHP 标记之后的文件顶部,例如
<?php error_reporting(E_ALL); ini_set('display_errors', 1);然后是其余代码,以查看它是否产生任何结果。 -
我在现场测试而不是 localhost@Kevin
-
您是否尝试过发送给不同的收件人?我问的原因是,如果您从域发送邮件并且该域具有 SPF 保护并且您的 IP 未列出,它将被大多数电子邮件服务器退回。
-
是的,我检查过不同的收件人,结果相同@detheridge02
标签: php sendmail html-email phpmailer