HighDots Forums  

PHP Form mail

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss PHP Form mail in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
madeirasun
 
Posts: n/a

Default PHP Form mail - 07-02-2008 , 11:19 AM






I used this script
http://www.visibilityinherit.com/cod...validation.php to produce a form
and everything worked fine on my site, which I was using for testing. When I
transferred over to the client's site it doesn't send the email. The error and
thank you messages work, but no email. As I have heard that some hosts block
some php files with the name 'formmail' I called it something else.
I have checked and rechecked all the data and only my email address and the
URLs for the error and thank you pages had to be changed, my email is correct,
but still not email.
Any ideas as to what is happening and how I can get around it please?

Rosalind


Reply With Quote
  #2  
Old   
bregent
 
Posts: n/a

Default Re: PHP Form mail - 07-02-2008 , 11:45 AM






What host is the client using? I believe that some, like GD, require an additional step to setup email accounts that will be processed via form scripts.

Reply With Quote
  #3  
Old   
madeirasun
 
Posts: n/a

Default Re: PHP Form mail - 07-02-2008 , 12:34 PM



Not GoDaddy,although supposedly a Portuguese host it is ns1.livedns.co.uk , which I think is FastHosts.co.uk.
Who has to perform the additional setup?

Rosalind

Reply With Quote
  #4  
Old   
bregent
 
Posts: n/a

Default Re: PHP Form mail - 07-02-2008 , 12:47 PM



Quote:
Who has to perform the additional setup?
With GD, the user needs to go to some page on their host control panel where
they enter the addresses of all form email recipients. It's not a bad idea as
it foils header injection and other abuse problems from poorly configured
scripts.



Reply With Quote
  #5  
Old   
madeirasun
 
Posts: n/a

Default 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 ;

?>



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.