Not receiving emails

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
therook
Forum Newbie
Posts: 4
Joined: Sat Feb 16, 2008 2:34 am

Not receiving emails

Post by therook »

Morning,

Wonder if anyone can help, I am new to all this?

I have tried to set up an enquiry form on our webpage which should email me the enquiry. I have obtained the script via http://www.sitewizard.com and have followed the instructions correctly.

When I trial it, it brings up my thank you page as if it has been set, but when I goto my webmail I do not receive it.

My host is streamline, and my package does include php scripting.

Can anyone point me in the right direction on what I need to do to resolve this?

If you require the script to look at, I am willing to post it.

Thanks inadvance
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Not receiving emails

Post by Benjamin »

If it's a script you have to buy don't post the entire thing. I think the first step would be a simple test:

Code: Select all

 
<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
 
mail($to, $subject, $message, $headers);
?>
 
Modify the email addresses and save this as a file on your webserver. Then pull it up in your browser and see if you get an email.

I'm assuming the script you bought is using the mail function. If it's using smtp or something else then that's a different issue.
therook
Forum Newbie
Posts: 4
Joined: Sat Feb 16, 2008 2:34 am

Re: Not receiving emails

Post by therook »

If it helps this is the script:

<?php
/*
CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.08
Generated by thesitewizard.com's Feedback Form Wizard.
Copyright 2000-2007 by Christopher Heng. All rights reserved.
thesitewizard and thefreecountry are trademarks of Christopher Heng.

Get the latest version, free, from:
http://www.thesitewizard.com/wizards/feedbackform.shtml

You can read the Frequently Asked Questions (FAQ) at:
http://www.thesitewizard.com/wizards/faq.shtml

I can be contacted at:
http://www.thesitewizard.com/feedback.php
Note that I do not normally respond to questions that have
already been answered in the FAQ, so *please* read the FAQ.

LICENCE TERMS

1. You may use this script on your website, with or
without modifications, free of charge.

2. You may NOT distribute or republish this script,
whether modified or not. The script can only be
distributed by the author, Christopher Heng.

3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
"AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
IMPLIED WARRANTY OF MECHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
SCRIPTS AND THE DOCUMENTATION.

If you cannot agree to any of the above conditions, you
may not use the script.

Although it is not required, I would be most grateful
if you could also link to thesitewizard.com at:

http://www.thesitewizard.com/

*/

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;

$mailto = 'enquiries@hair4weddings.me.uk' ;

// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;

$subject = "Enquiry Form" ;

// the pages to be displayed, eg
//$formurl = "http://www.example.com/feedback.html" ;
//$errorurl = "http://www.example.com/error.html" ;
//$thankyouurl = "http://www.example.com/thankyou.html" ;

$formurl = "http://www.hair4weddings.me.uk/feedback.html" ;
$errorurl = "http://www.hair4weddings.me.uk/error.html" ;
$thankyouurl = "http://www.hair4weddings.me.uk/thankyou.html" ;

$uself = 1;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$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 );
}

$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: chfeedback.php 2.08" );
header( "Location: $thankyouurl" );
exit ;

?>

</body>
</html>
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Not receiving emails

Post by Benjamin »

Post back after you have tested the code I posted.
therook
Forum Newbie
Posts: 4
Joined: Sat Feb 16, 2008 2:34 am

Re: Not receiving emails

Post by therook »

I have posted your script but still nothing

Regards
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Not receiving emails

Post by Benjamin »

Sounds like something is wrong with your server then. Contact your web hosting provider.
therook
Forum Newbie
Posts: 4
Joined: Sat Feb 16, 2008 2:34 am

Re: Not receiving emails

Post by therook »

Got it sorted. Needed to add the following for some reason:

ini_set("sendmail_from", "enquiries@hair4weddings.me.uk");

Thanks for you advice
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Not receiving emails

Post by Benjamin »

That is strange because your script and the one I posted from the manual are both setting the "From: " header.
Post Reply