我尝试使用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);
请有人给我解决方案来解决这个问题。感谢你。
答案 0 :(得分:0)
如果您要发送SMTP电子邮件,则需要输入smtp的以下信息
$host = "";
$port = "";
$username = "";
$password = "";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'MIME-Version'=>'1.0',
'Content-type'=>'text/html;charset=iso-8859-1');
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $message);