I'm getting following PHP Errors when using a Contact form, which worked fine until the client said that they aren't receiving emails since a week. As a friend helped me with the backend, and hes not available right now to ask, I wanted to ask kindly if you could give me a hint what I would need to fix.
The Errors:
`[Wed Feb 17 16:43:44 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Notice: Undefined variable: headers in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 29, referer: http://www.wscgmbh.de/contact.html
[Wed Feb 17 16:43:44 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Warning: mail(): Multiple or malformed newlines found in additional_header in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 32, referer: http://www.wscgmbh.de/contact.html
[Wed Feb 17 16:45:18 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Notice: Undefined variable: headers in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 29, referer: http://www.wscgmbh.de/contact.html
[Wed Feb 17 16:45:18 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Warning: mail(): Multiple or malformed newlines found in additional_header in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 32, referer: http://www.wscgmbh.de/contact.html
[Wed Feb 17 17:02:25 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Notice: Undefined index: name in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 12
[Wed Feb 17 17:02:25 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Notice: Undefined index: email in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 13
[Wed Feb 17 17:02:25 2016] [warn] [client 37.24.118.150] mod_fcgid: stderr: PHP Notice: Undefined index: message in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 14
[Thu Feb 18 09:40:15 2016] [warn] [client 213.23.122.15] mod_fcgid: stderr: PHP Notice: Undefined variable: headers in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 29, referer: http://www.wscgmbh.de/contact.html
[Thu Feb 18 09:40:15 2016] [warn] [client 213.23.122.15] mod_fcgid: stderr: PHP Warning: mail(): Multiple or malformed newlines found in additional_header in /var/www/vhosts/wscgmbh.de/httpdocs/php/contact-form-handler.php on line 32, referer: http://www.wscgmbh.de/contact.html`
This is the Code of the form-handler which worked the whole time, but suddenly doesnt
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
<?php
$errors = '';
$myemail = '[email protected]';
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z] {2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Sie haben eine neue Nachricht von: $name";
$email_body = "Sie haben eine neue Nachricht erhalten, hier sind die Details: \n\nName: $name \nEmail: $email_address \nNachricht: \n$message";
$headers [] .= 'From: WSC-Kontaktformular' . "\r\n";
$headers [] = "Antworten Sie: {$email_address}";
mail($to,$email_subject,$email_body,implode("\r\n",$headers));
//redirect to the 'thank you' page
echo '<script>
alert("Danke für Ihre Nachricht. Wir werden uns bald bei melden!");
window.location = "http://www.wscgmbh.de"
</script>';
}
?>
Im not an expert and PHP, so I really hope somebody could help me! Thank you very much in advance!!!
Antworten Sie:
in the headers which seems to translate toReply (to):
. I have edited my answer about it near the bottom of my answer and you need to reload it under Edit... – Funk Forty Niner