Hey guys I am trying to use PHP mailer to send an email through a contact form on my website.
I used these settings.
if (empty($errors)) {
$m = new PHPMailer;
$m->isSMTP();
$m->SMTPAuth = true;
$m->Host = 'smtp.gmail.com';
$m->Username = 'myemail@gmail.com';
$m->Password = 'its a correct password';
$m->SMTPSecure = 'ssl';
$m->Port = 465;
$m->isHTML();
$m->Subject = 'Submission of Contact form';
$m->Body = 'From:' . $fields['name'] . ' (' . $fields['email'] . ')<p>' .
$fields['message'] . '</p>';
$m->FromName = 'Contact';
$m->AddAddress('myemail@gmail.com', 'myname');
if ($m->send()) {
header('Location: thanks.php');
die();
} else {
$errors[] = 'Sorry, Try again later.';
}
}
I am new to PHP, but it seems that I have a syntax error somewhere that prevents the email from being sent. When I inspect the page I do get the 302 found and the 200 OK so it is working fine.
What am I missing in this code?