array(
'text' => 'Name',
'val' => $_POST['name']
),
1 => array(
'text' => 'Email address',
'val' => $_POST['email']
),
2 => array(
'text' => 'Message',
'val' => $_POST['message']
),
3 => array(
'text' => 'Checkboxes',
'val' => implode($_POST['checkboxes'], ", ")
),
4 => array(
'text' => 'Radios',
'val' => $_POST['radios']
)
);
$message = '';
foreach($fields as $field) {
$message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . " \n";
}
$mail = new PHPMailer(true);
try {
$mail->SMTPDebug = $debug; // Debug Mode
// Step 3 (Optional) - If you don't receive the email, try to configure the parameters below:
//$mail->IsSMTP(); // Set mailer to use SMTP
//$mail->Host = 'mail.yourserver.com'; // Specify main and backup server
//$mail->SMTPAuth = true; // Enable SMTP authentication
//$mail->Username = 'user@example.com'; // SMTP username
//$mail->Password = 'secret'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
//$mail->Port = 587; // TCP port to connect to
$mail->AddAddress($email); // Add a recipient
//$mail->AddAddress('person2@domain.com', 'Person 2'); // Add another recipient
//$mail->AddCC('person3@domain.com', 'Person 3'); // Add a "Cc" address.
//$mail->AddBCC('person4@domain.com', 'Person 4'); // Add a "Bcc" address.
$mail->SetFrom($email, $_POST['name']);
$mail->AddReplyTo($_POST['email'], $_POST['name']);
$mail->IsHTML(true); // Set email format to HTML
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
$mail->Body = $message;
// Step 4 - If you don't want to attach any files, remove that code below
if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['attachment']['tmp_name'], $_FILES['attachment']['name']);
}
$mail->Send();
$arrResult = array ('response'=>'success');
} catch (phpmailerException $e) {
$arrResult = array ('response'=>'error','errorMessage'=>$e->errorMessage());
} catch (Exception $e) {
$arrResult = array ('response'=>'error','errorMessage'=>$e->getMessage());
}
} else {
$arrResult = array ('response'=>'captchaError');
}
}
?>
Contact Us Advanced | Porto - Responsive HTML5 Template 5.7.2
Success! Your message has been sent to us.
Error! There was an error sending your message.
Error! Verification failed.
Contact Us
Get in Touch
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut feugiat urna arcu, vel molestie nunc commodo non. Nullam vestibulum odio vitae fermentum rutrum.
Mauris lobortis nulla ut aliquet interdum. Donec commodo ac elit sed placerat. Mauris rhoncus est ac sodales gravida. In eros felis, elementum aliquam nisi vel, pellentesque faucibus nulla.
The Office
Address: 1234 Street Name, City Name, United States
Phone: (123) 456-789
Email: mail@example.com
Business Hours
Monday - Friday - 9am to 5pm
Saturday - 9am to 2pm
Sunday - Closed