note 118991 deleted from function.mail by tularis
| From: | tularis@php.net | Date: | Mon, 14 Mar 2016 12:00:29 +0000 |
| Subject: | note 118991 deleted from function.mail by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205155@lists.php.net to get a copy of this message | ||
Note Submitter: HumanCK
----
I was working with this here to send my email with PHP, but for some reason it stopped working. May
someone of you have an idea what is wrong.
<?php
error_reporting(E_ALL ^ E_NOTICE);
if(isset($_POST['submitted'])) {
if(trim($_POST['contactName']) === '') {
$nameError = 'Sie haben ihren Namen vergessen.';
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}
if(trim($_POST['betreff']) === '') {
$betrError = 'Sie haben ihr Betreff - Anliegen vergessen.';
$hasError = true;
} else {
$betreff = trim($_POST['betreff']);
}
$telefon = trim($_POST['telefon']);
$company = trim($_POST['company']);
if(trim($_POST['email']) === '') {
$emailError = 'Sie haben ihre Email Adresse vergessen.';
$hasError = true;
} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i",
trim($_POST['email']))) {
$emailError = 'Sie haben ihre Email Adresse falsch eingegeben.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(trim($_POST['comments']) === '') {
$commentError = 'Sie haben ihre Nachricht vergessen.';
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = utf8_encode(stripslashes(trim($_POST['comments'])));
} else {
$comments = trim($_POST['comments']);
}
}
if(!isset($hasError)) {
$emailTo = 'example@example.com';
$subject = 'Kobsche.de - '.$name.' - '.$betreff;
$sendCopy = trim($_POST['sendCopy']);
$body = "\n\nDies ist eine Email von ihrem Kontakt Formular auf der Webseite http://www.example.com/\nAlle uebermittelten Daten des
Benutzers durch das Formular finden sie unterhalb dieses Textes.\n\nFirma - Unternehmen :
$company\n\nName - Ansprechpartner : $name \n\nEmail-Adresse : $email \n\nTelefon-Nr. : $telefon
\n\nBetreff - Anliegen : $betreff\n\nNachricht des Nutzers: $comments\n\n";
$headers = "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n";
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}
?>