php - Trying to send mail to user and admin at same time -


<?php include("include/head.php"); include("include/headder.php");  if(isset($_post['submitfrm'])) { if($_request['captchares'] != 1) { echo "<script> window.location='page-full-width.php?capterror'; </script>";  exit; } else { $username=$_request['username']; $useremail=$_request['useremail']; $mobile=$_request['mobile']; $comment=$_request['comment'];     $contact=mysql_query("insert `contactus` (`username`, `useremail`, `mobile`, `comment`) values ('$username', '$useremail', '$mobile', '$comment')");   $conatctid=mysql_insert_id();   if($contact) {  $mail = new phpmailer(); // create new object $mail->issmtp(); // enable smtp $mail->smtpdebug = 0; // debugging: 1 = errors , messages, 2 = messages $mail->smtpauth = true; // authentication enabled //$mail->smtpsecure = 'ssl'; // secure transfer enabled required gmail $mail->host = $smtphost; $mail->port = 25; // or 587 $mail->ishtml(true); $mail->username = $smtpmail; $mail->password = $smtppassword; $mail->setfrom = $smtpmail; $mail->subject = "enquiry"; $mail->body = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='#006699' style='border:solid 10px #006699; width:550px;'> <tr bgcolor='#006699' height='25'> <td><img src='$sitelogo' border='0' width='200' height='60' /></td> </tr> <tr bgcolor='#ffffff'> <td>&nbsp;</td> </tr> <tr bgcolor='#ffffff' height='30'> <td valign='top' style='font-family:arial; font-size:12px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'>this mail sent <b> $website_name </b> regarding enquiry</td></tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>our support team soon,  dear $username </td> </tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>we response :$useremail</td> </tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>our notifications , offers sent per willingness :$mobile</td> </tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>your enquiry :$comment</td> </tr> </table>"; $mail->addaddress($useremail); if(!$mail->send()) { echo "mailer error: " . $mail->errorinfo; } else { //==================================send mail admin==========================================  $mail = new phpmailer(); // create new object $mail->issmtp(); // enable smtp $mail->smtpdebug = 0; // debugging: 1 = errors , messages, 2 = messages $mail->smtpauth = true; // authentication enabled //$mail->smtpsecure = 'ssl'; // secure transfer enabled required gmail $mail->host = $smtphost; $mail->port = 25; // or 587 $mail->ishtml(true); $mail->username = $smtpmail; $mail->password = $smtppassword; $mail->setfrom = $useremail; $mail->subject = "enquiry"; $mail->body = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='#006699' style='border:solid 10px #006699; width:550px;'> <tr bgcolor='#006699' height='25'> <td><img src='$sitelogo' border='0' width='200' height='60' /></td> </tr> <tr bgcolor='#ffffff'><td>&nbsp;</td></tr> <tr bgcolor='#ffffff' height='30'> <td valign='top' style='font-family:arial; font-size:12px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'>this mail sent <b> $website_name </b> regarding enquiry</td></tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>user name: $username </td> </tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>user email: $useremail</td> </tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>user mobile: $mobile</td> </tr> <tr bgcolor='#ffffff' height='35'> <td style='padding-left:20px; font-family:arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>user enquiry :$comment</td> </tr> </table>"; $mail->addaddress($website_admin); //============================================================================================== echo "<script> window.location='page-full-width.php?sent'; </script>";  exit;  } } } } 

mail sending user mail not receiving admin.. me out please.. want send mail user when send inquiry , admin user inquiry product.

following comment, i'll post answer seems source of problem.

you forgot write $mail->send(); right after $mail->addaddress($website_admin);.

that why mail hasn't been sent. haven't told php so.

add line (as did first email) , you'd go.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -