我在完成用户付款后正在使用支付网关,我正在成功页面上发送确认信息的用户。
现在我想在用户邮件中发送此确认信息,以便用户可以从电子邮件中下载。所以我知道如何才能完成。
由于
答案 0 :(得分:4)
您可以显示确认订单的页面,也可以让PHP向用户发送电子邮件,
您可以让PHP发送HTML电子邮件,如下所示:
$to = $email;
$subject = 'Order Confirmed';
$message = '<html>This is an email to confirm that '.$OrderID.' has been acknowledged.</html>';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Website <noreply@mysite.com>' . "\r\n";
mail($to, $subject, $message, $headers);
要附加PDF文档,最好的方法是使用FPDF生成它。 然后,您可以将PDF附加到自动发送的电子邮件中。
$to = $email;
$subject = 'Order Confirmed';
$message = '<html>This is an email to confirm that '.$OrderID.' has been acknowledged.</html>';
// attachment name
$InvoiceFilename = "Invoice$OrderID.pdf";
// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$pdf->Output(F,'../uploads/Invoice'.$OrderID.'.pdf');
//$pdf->Output();
$attachment = chunk_split(base64_encode($pdfdoc));
// main header
$headers = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
// no more headers after this, we start the body! //
$body = "--".$separator.$eol;
$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$body .= "This is a MIME encoded message.".$eol;
// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol;
// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$InvoiceFilename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--";
// send message
mail($to, $subject, $body, $headers);