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.
<?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");
?>

Open in new window

danwpetersAsked:
Who is Participating?
 
agamalCommented:
you didn't send the second mail

        if(!$mail->Send())

0
 
danwpetersAuthor Commented:
Ah, thanks aqamal!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.