Re: PHP Form mail -
07-04-2008
, 12:30 PM
I have been sent the following information and code, but have not succeeded in
working out where to add it. The code I am using is underneath. Many thanks
- to send emails through our servers you must comply with one of the following
rules
a. The sending email must be from your domain
b. The receiving email must be from your domain
This account could/should be geral (AT) formosaparadise (DOT) com
- To avoid a wrong use of our scripts by spammers you must had a line before
you call the ?mail? functionality
ini_set("sendmail_from", " user (AT) yourdomain (DOT) com ");
- Please add to the email send code a functionality ?-f? in the fifth
parameter of the function send mail
- This is the simple configuration of sending emails in php
<?php
ini_set("sendmail_from", user (AT) yourdomain (DOT) com);
mail($email_to, $email_subject, $email_message, $headers,
'-f'user (AT) yourdomain (DOT) com);
?>
my php code is
<?php
// Input Your Personal Information Here
$mailto = 'myemail (AT) mydomain (DOT) com' ;
$from = "FormosaParadise.com" ;
$formurl = "http://formosaparadise.com/correios.php" ;
$errorurl = "http://formosaparadise.com/formmailerror.php" ;
$thankyouurl = "http://formosaparadise.com/thankyou.php" ;
// End Edit
// prevent browser cache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function remove_headers($string) {
$headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i"
);
if (preg_replace($headers, '', $string) == $string) {
return $string;
} else {
die('You think Im spammy? Spammy how? Spammy like a clown, spammy?');
}
}
$uself = 0;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
if (!isset($_POST['email'])) {
header( "Location: $errorurl" );
exit ;
}
// Input Your Personal Information Here
$name = remove_headers($_POST['name']);
$email = remove_headers($_POST['email']);
$phone = remove_headers($_POST['phone']);
$comments = remove_headers($_POST['comments']);
$http_referrer = getenv( "HTTP_REFERER" );
// End Edit
if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i",$email)) {
header( "Location: $errorurl" );
exit ;
}
// Input Your Personal Information Here
if (empty($name) || empty($email) || empty($phone) ||empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
// End Edit
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
// sets max amount of characters in comments area (edit as nesesary)
if (strlen($comments) > 1250) {
$comments=substr($comments, 0, 1250).'...';
}
// End Edit
$message =
"This message was sent from:\n" .
"$http_referrer\n\n" .
// Input Your Personal Information Here
"Name: $name\n\n" .
"Email: $email\n\n" .
"Phone No: $phone\n\n" .
"Comments: $comments\n\n" .
"\n\n------------------------------------------------------------\n" ;
// End Edit
mail($mailto, $from, $message,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
$headersep );
header( "Location: $thankyouurl" );
exit ;
?> |