Hey there,
For my contact form I am still using the old quickcontact.php and PHP mail but the emails stopped sending.
So I wanna change to SMTP.
Can I still use quickcontact.php and how would I have to change it?
Currently it looks like this:
'info@dirazi.de', // Your Email Address
'email' => 'torsten.voll@gmail.com',
'name' => 'Manfred Jung' // Your Name
);
// Form Processing Messages
$message_success = 'Wir haben Ihre Nachricht soeben **erhalten** und werden uns umgehend mit Ihnen in Verbindung setzen!';
// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = ''; // Your reCaptcha Secret
$mail = new PHPMailer();
// If you intend you use SMTP, add your SMTP Code after this Line
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if( $_POST['quick-contact-form-email'] != '' ) {
$name = $_POST['quick-contact-form-name'];
$email = $_POST['quick-contact-form-email'];
$message = $_POST['quick-contact-form-message'];
$subject = 'New Message From Quick Contact Form';
$botcheck = $_POST['quick-contact-form-botcheck'];
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
foreach( $toemails as $toemail ) {
$mail->AddAddress( $toemail['email'] , $toemail['name'] );
}
$mail->Subject = $subject;
$name = isset($name) ? "Name: $name
" : '';
$email = isset($email) ? "E-Mail: $email
" : '';
$message = isset($message) ? "Nachricht: $message
" : '';
$referrer = $_SERVER['HTTP_REFERER'] ? '
Mitteilung über das Kontaktformular: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$name $email $message $referrer";
// 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;
// }
$mail->MsgHTML( $body );
$mail->CharSet = "UTF-8";
$sendEmail = $mail->Send();
if( $sendEmail == true ):
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;
} else {
echo '{ "alert": "error", "message": "Bot **Detected**.! Clean yourself Botster.!" }';
}
} else {
echo '{ "alert": "error", "message": "Please **Fill up** all the Fields and Try Again." }';
}
} else {
echo '{ "alert": "error", "message": "An **unexpected error** occured. Please Try Again later." }';
}
?>Cheers,
Torsten
