So I am using and successfully sending emails out using PHPmailer yet once the email sends I am not sure where to put the page redirect back to the page you came from with a message saying message sent perhaps?
<?php
if (isset($_POST['hp']) && $_POST['hp'] && $_POST['hp'] != '') {
}
else {
require 'c:\php\includes\PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ''; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ''; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->Port =;
$mail->From = '';
$mail->FromName = '';
foreach ($members as $user) {
$mail->addAddress($user->user_email);
}
foreach ($committee as $user) {
$mail->AddCC($user->user_email);
}
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST["Subject"];
$mail->Body = $_POST["contentfield"];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
}
?>
I have taken all my details out for obvious reasons.