Send multiple mail is not happening

Thanks in advance to all. I am designing a shopping cart in php and mysql. I want to send order confirmation email to the client and also to admin registered email-id. My email function is

      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;
    }  

    }

Now the problem is when I triggered the function to send mail, only customer email is sent but admin email is not sending. I have tried to input sleep function, use the same function in a different name, but all gone in vain. The absurd thing is that if I changed the order of the mail, only customer mail is sending. Please help me to solve the problem. thank you. the very code is

    $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}");    

      }
链接地址: http://www.djcxy.com/p/69342.html

上一篇: 在使用php发送电子邮件时没有配置错误

下一篇: 发送多个邮件不会发生