提前感谢所有人。我正在设计一个php和mysql的购物车。我想向客户发送订单确认电子邮件,也发送管理员注册的电子邮件ID。我的电子邮件功能是
function send_mail($address,$subject,$message,$path){
global $error;
$mail = new PHPMailer();
//$mail->isSMTP();
//$mail->SMTPDebug = 1; // Enable verbose debug output
//$mail->SMTPAuth = true;
//$mail->SMTPSecure ='ssl' ;
//$mail->Host ="smtp.mail.yahoo.com";
//$mail->Port = '465'; // use 587 also
//$mail->Username = "";
//$mail->Password = "";
$mail->setFrom("sales@dressncrafts.com", "Dress N Crafts");
$mail->addReplyTo("sales@dressncrafts.com", "Dress N Crafts");
$mail->addAddress($address); // Add a recipient
$mail->Subject = $subject;
//$mail->AltBody = $message; // optional, comment out and test
$mail->MsgHTML($message);
$mail->addAttachment($path); // attachment
$send = $mail->send();
$mail->clearAddresses();
$mail->clearAttachments();
if(!$send) {
return FALSE;
} else {
return TRUE;
}
}
现在问题是当我触发发送邮件的功能时,只发送了客户电子邮件,但管理员电子邮件没有发送。我试图输入睡眠功能,使用不同名称的相同功能,但都是徒劳。荒谬的是,如果我改变了邮件的顺序,只有客户邮件正在发送。请帮我解决问题。谢谢。代码是
$message = "Hello $name, your order (order number:$ordernumber) has been
placed on the date $date with the following details."
.'<br><br><center>'.$body.'</center><br>'."Subtotal:Rs.
$subtotal".'<br>'."Delivery Charges:Extra".'<br>'."Total:Rs.
$total".'<br>'.
"Your order is under process and the invoice is attached with the
mail.Please find it.".'<br><br>'.
"Thanking you".'<br>'.$about->getShopname();
$subject = "Successful order";
$cust_mail=send_mail($email,$subject,$message,$invpath);
$shopsubject = "New Order";
$shop_email= $about->getEmail();
$shop_mail= send_mail($shop_email,$shopsubject,"New order has arrived, find
the attachment",$invpath);
if($shop_mail==TRUE && $cust_mail==TRUE){
foreach($cartresult as $cres)
{
$cart->setIdcart($cres->idcart);
$cart->deleteCart();
}
redirect("../checkout.php?plsord=TRUE&cust={$cust_mail}&shop=
{$shop_mail}");
}
else {
foreach($cartresult as $cres)
{
$cart->setIdcart($cres->idcart);
$cart->deleteCart();
}
redirect("../checkout.php?plsord=TRUE&some=false&cust=
{$cust_mail}&shop={$shop_mail}");
}