Help with mail script

This is a discussion on Help with mail script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I use the script below to send a email from a contact form but it would be nice if ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 1 Week Ago
Joker7
 
Posts: n/a
Default Help with mail script




Hi,
I use the script below to send a email from a contact form but it would be
nice if the conformed sent page showed what was sent.Question how can I do
this ?

Thanks
Chris

<?php
$mailto = 'email@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
$headersep . "X-Mailer: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>


Reply With Quote
  #2 (permalink)  
Old 1 Week Ago
Erwin Moller
 
Posts: n/a
Default Re: Help with mail script

Joker7 schreef:
> Hi,
> I use the script below to send a email from a contact form but it would be
> nice if the conformed sent page showed what was sent.Question how can I do
> this ?
>
> Thanks
> Chris
>
> <?php
> $mailto = 'email@mail.co' ;
> $subject = "Feedback Form" ;
> $formurl = "http://page.co/ of form" ;
> $errorurl = "http://page.co/contact.php" ;
> $thankyouurl = "http://page.co/thankyou.php" ;
> $uself = 1;
> $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
> $name = $_POST['name'] ;
> $email = $_POST['email'] ;
> $comments = $_POST['comments'] ;
> $http_referrer = getenv( "HTTP_REFERER" );
>
> if (!isset($_POST['email'])) {
> header( "Location: $formurl" );
> exit ;
> }
> if (empty($name) || empty($email) || empty($comments)) {
> header( "Location: $errorurl" );
> exit ;
> }
> if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
> header( "Location: $errorurl" );
> exit ;
> }
>
> if (get_magic_quotes_gpc()) {
> $comments = stripslashes( $comments );
> }
>
> if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
> referrer");
>
> }
>
> $messageproper =
>
> "This message was sent from:\n" .
> "$http_referrer\n" .
> "------------------------------------------------------------\n" .
> "Name of sender: $name\n" .
> "Email of sender: $email\n" .
> "------------------------- COMMENTS -------------------------\n\n" .
> $comments .
> "\n\n------------------------------------------------------------\n" ;
>
> mail($mailto, $subject, $messageproper,
> "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
> $headersep . "X-Mailer: Feed Back" );
> header( "Location: $thankyouurl" );
> exit ;
>
> ?>
>
>


Hi,

http://nl2.php.net/manual/en/function.mail.php

says for returnvalue of your mail command:
Quote:
Return Values
Returns TRUE if the mail was successfully accepted for delivery, FALSE
otherwise.
It is important to note that just because the mail was accepted for
delivery, it does NOT mean the mail will actually reach the intended
destination.
So just change it in:
$mailresult = mail(..yourstuffhere..);

And then use the value for $mailresult to display if the sending was
succesful.

echo (($mailresult) ? "SUCCES!":"PROBLEM WITH SENDING" );

Regards,
Erwin Moller
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:36 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0