I've been using phpmailer for a contact form recently, but when I try to send the contact form to the email it results into an error. Any help will be appreciated! Keep in mind that this is using xampp localhost. Also my contact.php redirects to another page which ma My error is
2016-02-21 00:02:19 Invalid address: (addAnAddress Reply-To): 11 Notice: Undefined property: PHPMailer::$send in C:\xampp\htdocs\Guild Website\contact.php on line 51
Contact.php script is also -
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
session_start();
require_once 'libs/phpmailer/PHPMailerAutoload.php';
$errors = [];
if(isset($_POST['name'], $_POST['email'], $_POST['ign'], $_POST['gamepref'], $_POST['cps'], $_POST['anythingelse'])) {
$fields = [
'name' => $_POST['name'],
'e-mail' => $_POST['email'],
'IGN' => $_POST['ign'],
'game preference' => $_POST['gamepref'],
'CPS' => $_POST['cps'],
'anything else' => $_POST['anythingelse'],
];
foreach($fields as $field => $data) {
if(empty($data)) {
$errors[] = "The $field field is required.";
}
}
if(empty($errors)) {
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->Username = 'somemail@gmail.com';
$mail->Password = 'pass';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->isHTML();
$mail->Subject = '$fields[\'name\'] is wanting to apply.';
$mail->Body = '<p>Name: $fields[\'name\']</p><p>E-Mail: $fields[\'e-mail\']</p><p>IGN: $fields[\'IGN\']</p><p>Game Preference: $fields[\'game preference\']</p><p>CPS: $fields[\'CPS\']</p><p>Message: $fields[\'anything else\']</p>';
$mail->FromName = 'Contact';
$mail->AddReplyTo($fields['e-mail'], $fields['name']);
$mail->AddAddress('somemail@gmail.com');
if($mail->send) {
header('Location: thanks.php');
die();
} else {
$errors[] = 'Sorry, could not send email. Try again later.';
}
}
} else {
$errors[] = "Something went wrong! (Mabye it is because you didn't put anything!)";
}
$_SESSION['errors'] = $errors;
$_SESSION['fields'] = $fields;