tom_b Posted February 7, 2007 Share Posted February 7, 2007 Hi, Well, I got my mail server working, I can now send e-mails from my computer, however, the message doesn't show up when i get the e-mail, here's the script: <?php $sendTo = "[email protected]"; $subject = "php e-mail test"; $headers = "From: Tom "; $message = "this is the message"; //$headers = "Reply-To: " . $_POST["email"] . "\r\n"; //$headers = "Return-Path: " . $_POST["email"]; mail($sendTo, $subject, $headers, $message); ?> What' wrong here? Thanks, Tom Link to comment https://forums.phpfreaks.com/topic/37391-php-email-script/ Share on other sites More sharing options...
Wuhtzu Posted February 7, 2007 Share Posted February 7, 2007 First of all you have to use the correct syntax for mail(): http://no.php.net/manual/en/function.mail.php bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] ) So your piece of code will look like: mail($sendTo, $subject, $message, $headers); And when you are dealing with functions that return false for failure and true for success you should use it: <?PHP $sendmail = mail($sendto,$subject,$message,$headers); if($sendmail){ echo "Mail sent successfully"; } else{ echo "Sending failed.."; } ?> If the mail is succesfully sent $sendmail will be set to true and your script will print "Mail sent successfully", otherwise it will print "Sending failed..". Link to comment https://forums.phpfreaks.com/topic/37391-php-email-script/#findComment-178732 Share on other sites More sharing options...
Wuhtzu Posted February 7, 2007 Share Posted February 7, 2007 I missed the // in front of both your $headers and actually misunderstood your problem You do receive the e-mail due to a little bit of luck: #1: You do use the wrong syntax: mail($sendto,$subject,$headers,$message) which should have been: mail($sendto,$subject,$message,$headers) #2: Therefore the script sends $headers as the message and $headers is empty because you have commented those out using // hence the "message is not showing up" #3: And for some reason it can deal with "this is the message" as a header and does not give you an error.... Best regards Wuhtzu Link to comment https://forums.phpfreaks.com/topic/37391-php-email-script/#findComment-178737 Share on other sites More sharing options...
tom_b Posted February 7, 2007 Author Share Posted February 7, 2007 Hi!! Yes, I"ve been getting the e-mails just fine, but no messages. Once I put "$message" in the right place it worked just fine!!!!! Thanks, Tom Link to comment https://forums.phpfreaks.com/topic/37391-php-email-script/#findComment-178740 Share on other sites More sharing options...
tom_b Posted February 7, 2007 Author Share Posted February 7, 2007 One other quick question if I could, why are the e-mails coming to my bulk folder??? Link to comment https://forums.phpfreaks.com/topic/37391-php-email-script/#findComment-178743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.