I have a code here to send an email to the client and to the admin. So far it's sending to the client but I can't figure out why it is not sending to the admin please help.
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddAddress($email);
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->From= $admin_email;
$mail->FromName= "Chinchilla Scientific";
$mail->Body = $user_message;
if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddAddress($admin_email);
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->From = $email;
$mail->FromName= $name;
$mail->Body = $admin_message;
exit;
try this...you dont need to use it twice
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddAddress($email);
$mail->AddBCC($admin_email); // change here
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->From= $admin_email;
$mail->FromName= "Chinchilla Scientific";
$mail->Body = $user_message;
if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}
You can use the PHP mail function directly without using the PHP mailer
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "
";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "
";
$headers .= 'Cc: birthdayarchive@example.com' . "
";
$headers .= 'Bcc: birthdaycheck@example.com' . "
";
// Mail it
mail($to, $subject, $message, $headers);
?>
just be sure to test this on live servers not in the localhost
use mailer code twince
put below code at last
if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}