Your system did not allow the PHP code to be included as an attachement, so here's the code:
IsSMTP();
$mail->Host = "smtp.dreamhost.com";
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls'; // -- TLS encryption, `ssl` also accepted
$mail->Port = 587; // -- TCP port
$mail->Username = "dispatch@cahins.work";
$mail->Password = "hdNCWua-";
$mail->setFrom('dispatch@cahins.work', 'Dispatch');
$mail->addAddress('developer@xentient.technology', 'Developer');
$mail->Subject = 'TEST';
$mail->isHTML(true);
$mail->Body = 'Testing messages using **HTML!**';
switch ($submit_type) {
case "cli":
$submit_status = $mail->Send();
break;
case "cgi-fcgi":
case "apache2handler":
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if( $_POST['template-contactform-email'] != '' ) {
// -- Pull all of the email data from the POST
//
$name = isset( $_POST['template-contactform-name'] ) ? $_POST['template-contactform-name'] : '';
$email = isset( $_POST['template-contactform-email'] ) ? $_POST['template-contactform-email'] : '';
$phone = isset( $_POST['template-contactform-phone'] ) ? $_POST['template-contactform-phone'] : '';
$service = isset( $_POST['template-contactform-service'] ) ? $_POST['template-contactform-service'] : '';
$subject = isset( $_POST['template-contactform-subject'] ) ? $_POST['template-contactform-subject'] : '';
$message = isset( $_POST['template-contactform-message'] ) ? $_POST['template-contactform-message'] : '';
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
// -- [CAM 2018-12-19] Route the email to the proper recipient, depending on the service selected:
//
// switch ($service) {
// case "Business":
// $mail->AddAddress( 'scrawford@cahins.com' , 'Stacey Crawford' );
// break;
// case "Benefits":
// $mail->AddAddress( 'tjiles@cahins.com' , 'Tiffany Jiles' );
// break;
// case "Claim":
// $mail->AddAddress( 'claims@cahins.com' , 'Claims Dept' );
// break;
// case "Certification":
// $mail->AddAddress( 'cert@cahins.com' , 'Certifications' );
// break;
// default:
// $mail->AddAddress( 'cknotts@cahins.com' , 'Christopher Knotts' );
// break;
// }
// -- Compose the HTML message
//
$name = isset($name) ? "**Name:** $name
" : '';
$email = isset($email) ? "**Email:** $email
" : '';
$phone = isset($phone) ? "**Phone:** $phone
" : '';
$service = isset($service) ? "**Service:** $service
" : '';
$subject = isset($subject) ? "**Subject:** $subject
" : '';
$message = isset($message) ? "**Message:** $message
" : '';
$mail->Subject = '[Website Contact Form] RE: ' . strip_tags($service) . ' ';
$mail->Body = "
$name $email $phone $service $subject $message
";
// -- Runs only when reCaptcha is present in the Contact Form
//
if( isset( $_POST['g-recaptcha-response'] ) ) {
$recaptcha_response = $_POST['g-recaptcha-response'];
$response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response );
$g_response = json_decode( $response );
if ( $g_response->success !== true ) {
echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
die;
}
}
// -- Uncomment the following Lines of Code if you want to Force reCaptcha Validation
//
if( !isset( $_POST['g-recaptcha-response'] ) ) {
echo '{ "alert": "error", "message": "Captcha not Submitted! Please Try Again." }';
die;
}
// == Send the email
//
$submit_status = $mail->Send();
}
else {
echo '{ "alert": "error", "message": "Please fill up **all the fields** and try again." }';
}
}
break;
default:
echo 'Unknown Submission type
';
break;
}
// -- Send an acknowledgement message if successful, otherwise send an error message
//
if($submit_status):
echo '{ "alert": "success", "message": "' . $message_success . '" }';
else:
echo '{ "alert": "error", "message": "Email **could not** be sent due to some unexpected error. Please try again later. **Reason:** ' . $mail->ErrorInfo . '" }';
endif;
}
// -- Exception Handlers:
//
catch (Exception $e)
{
echo $e->errorMessage();
}
catch (\Exception $e)
{
echo $e->getMessage();
}