danwpeters
asked on
php mailer confirmation email
How do I send 2 different emails in phpmailer?
I want to send a confirmation email to the submitter, as well as send the results to the admin.
I've got it working in phpmailer-fe but I find it too bloated for my needs. So really need to get it working in the standard php mailer.
I want to send a confirmation email to the submitter, as well as send the results to the admin.
I've got it working in phpmailer-fe but I find it too bloated for my needs. So really need to get it working in the standard php mailer.
<?php
/*
* Process the form and send an email, then redirect to the thank you page.
*/
require("../../phpmailer/class.phpmailer.php");
$crm = $title."~".
$firstname."~".
$surname;
/* start results email */
$mail = new PHPMailer();
$mail->From = "email@email.com";
$mail->FromName = "Site";
$mail->Subject = $crm;
$mail->Mailer = "smtp";
$to = "admin@email.com";
$toName = "Admin";
$htmltextmessage="
<font style='font-family:Arial;font-size:13px;'>
The following enquiry has been made:
<br /><br />
Title: $title
<br /><br />
Firstname: $firstname
<br /><br />
Surname: $surname
</font>
";
$plaintextmessage ="\n";
$mail->Body = $htmltextmessage;
$mail->AltBody = $plaintextmessage;
$mail->AddAddress($to, $toName);
if(!$mail->Send())
{
header("Location: fail.php");
}
/* end results email */
/* Start thank you email */
$mail = new PHPMailer();
$mail->From = "email@email.com";
$mail->FromName = "Site";
$mail->Subject = "Thank you";
$mail->Mailer = "smtp";
$to = $email;
$toName = $firstname ." ". $surname;
$htmltextmessage="
<font style='font-family:Arial;font-size:13px;'>
$firstname $surname!<br />
<br />This is a confirmation email!
</font>
";
/* End thank you email */
$plaintextmessage2 ="\n";
$mail->Body = $htmltextmessage;
$mail->AltBody = $plaintextmessage;
$mail->AddAddress($to, $toName);
header("Location: frontend.php");
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER