Your email was successfully sent. I will be in touch soon.
';
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
// Read in options
$arixwp_mailto = trim( get_post_meta( get_the_ID(), '_arixwp_mailto', TRUE ) );
$arixwp_mailtodept = trim( get_post_meta( get_the_ID(), '_arixwp_mailtodept', TRUE ) );
$arixwp_mailsubject = trim( get_post_meta( get_the_ID(), '_arixwp_mailsubject', TRUE ) );
$arixwp_publickey = trim( get_post_meta( get_the_ID(), '_arixwp_publickey', TRUE ) );
$arixwp_privatekey = trim( get_post_meta( get_the_ID(), '_arixwp_privatekey', TRUE ) );
$arixwp_bizname = trim( get_post_meta( get_the_ID(), '_arixwp_bizname', TRUE ) );
$arixwp_yourname = trim( get_post_meta( get_the_ID(), '_arixwp_yourname', TRUE ) );
$arixwp_address1 = trim( get_post_meta( get_the_ID(), '_arixwp_address1', TRUE ) );
$arixwp_address2 = trim( get_post_meta( get_the_ID(), '_arixwp_address2', TRUE ) );
$arixwp_city = trim( get_post_meta( get_the_ID(), '_arixwp_city', TRUE ) );
$arixwp_state = trim( get_post_meta( get_the_ID(), '_arixwp_state', TRUE ) );
$arixwp_country = trim( get_post_meta( get_the_ID(), '_arixwp_country', TRUE ) );
$arixwp_postal = trim( get_post_meta( get_the_ID(), '_arixwp_postal', TRUE ) );
$arixwp_phone = trim( get_post_meta( get_the_ID(), '_arixwp_phone', TRUE ) );
$arixwp_mobile = trim( get_post_meta( get_the_ID(), '_arixwp_mobile', TRUE ) );
$arixwp_fax = trim( get_post_meta( get_the_ID(), '_arixwp_fax', TRUE ) );
$arixwp_facebook = trim( get_post_meta( get_the_ID(), '_arixwp_facebook', TRUE ) );
$arixwp_twitter = trim( get_post_meta( get_the_ID(), '_arixwp_twitter', TRUE ) );
$arixwp_googleplus = trim( get_post_meta( get_the_ID(), '_arixwp_googleplus', TRUE ) );
$arixwp_linkedin = trim( get_post_meta( get_the_ID(), '_arixwp_linkedin', TRUE ) );
$nameError = "";
$emailError = "";
$subjectError = "";
$commentError = "";
$urlError = "";
// See if form was submitted
if ( isset( $_POST[ 'arixwp_mailform'] ) ) {
// Validate URL (spambot)
$url = filter_input( INPUT_POST, 'url', FILTER_SANITIZE_STRING );
if ( !isset($url) ) {
} else {
$emailSent = true;
}
// Validate Department
$deptEmail = filter_input(INPUT_POST, 'deptName', FILTER_SANITIZE_STRING);
// Validate Name
$contactName = filter_input(INPUT_POST, 'contactName', FILTER_SANITIZE_STRING);
if ($contactName == '') {
$nameError = 'Please enter a valid name.';
$hasError = true;
}
// Validate Email
$email = filter_input( INPUT_POST, 'email', FILTER_SANITIZE_EMAIL );
if (!filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
$emailError = '' . $email . ' is NOT a valid email address.';
$hasError = true;
}
// Validate Subject
$subject = filter_input( INPUT_POST, 'subject' , FILTER_SANITIZE_STRING );
if ($subject == '') {
$subjectError = 'Please enter a valid subject.';
$hasError = true;
}
// Validate Message
$message = filter_input( INPUT_POST, 'message', FILTER_SANITIZE_STRING);
if ($message == '') {
$commentError = 'Please enter a message to send.
';
$hasError = true;
}
// If we didn't hit an error, send the email
if (!isset($hasError) ) {
// Body:
$body = '
Name: ' . $contactName . '
Email: ' . $email . '
Comments: ' . $message . '
';
// Headers
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n";
// Send it
if ($deptEmail != "") {
mail($deptEmail, $arixwp_mailsubject . ' : ' . $subject , $body, $headers);
} else {
$arixwp_mailto = explode(',',$arixwp_mailto);
mail($arixwp_mailto[0], $arixwp_mailsubject . ' : ' . $subject , $body, $headers);
}
$emailSent = true;
}
}
// Output template
if (isset($emailSent) && $emailSent == true) {
echo '
Your email was successfully sent. I will be in touch soon.