garydt Posted July 4, 2007 Share Posted July 4, 2007 I've copied an email script from a page where it works to a second page. I'm not recieving test emails from the second page and i can't understand why. $to = 'garydt@tiscali.co.uk'; echo $to; //from you the sender. $from = 'me'; $subject = "from epeople"; $mess = "password is $psw"; $message = $mess; $headers = "From: $from\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // send if correct. if (mail($to, $subject, $message, $headers)) { echo $psw; } Thanks Quote Link to comment Share on other sites More sharing options...
dewey_witt Posted July 4, 2007 Share Posted July 4, 2007 Gary there are a number of things that could be fouled in an email script. Here is a snippet i hope helps: $msg = "Topic of e-mail goes here\nThe information is:\n\n"; $msg .= "First name: " . $_POST[FName] . "\n"; $msg .= "Lastname: " . $_POST[LName] . "\n"; $msg .= "Email: " . $_POST . "\n"; $msg .= "Organization: " . $_POST[Org] . "\n"; $msg .= "Address: " . $_POST[Addy] . "\n"; $msg .= "City: " . $_POST[City] . "\n"; $msg .= "State: " . $_POST[state] . "\n"; $msg .= "Zip: " . $_POST[Zip] . "\n"; $msg .= "Phone: " . $_POST[Phone] . "\n\n"; $to = "receipiant@somedomain.com"; $subject = "The subject of the e-mail goes here"; $headers = "From: sender@sendersdomain.com\n"; $headers .= "Reply-To: sender@senders domain.com\n\n"; mail($to, $subject, $msg, $headers); //sends the poster to a specified location after the script runs. header( "Location: http://www.somelocation.com"); exit; Also it depends on your hosting. If your hosting is windows most hosting providers run php in "safe mode" on windows... this doesnt allow for e-mail scripts in php. I recently had this problem with godaddy. Their tech support knew nothing I called 823765928365 times untill finaly someone had some info for me on the matter. WORD OF ADVICE: DO NOT HOST ON GODADDY WINDOWS HOSTING!!! Their linux servers are awsome tho Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 4, 2007 Share Posted July 4, 2007 Try removing this line: "Content-Transfer-Encoding: 8bit\r\n\r\n"; Quote Link to comment Share on other sites More sharing options...
garydt Posted July 4, 2007 Author Share Posted July 4, 2007 Thanks. It still doesn't work, yet it works on other page. very frustrating. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 4, 2007 Share Posted July 4, 2007 so i take it the if statement is returning true? if some you have a logical error in the mail. Have you sent mail before from your server? a lot of times the issue is your end client is black listing a subdomain Quote Link to comment Share on other sites More sharing options...
Hypnos Posted July 4, 2007 Share Posted July 4, 2007 Try just this to make sure the email settings on your server are correct. $to = 'garydt@tiscali.co.uk'; mail($to, "Test email from PHP", "Test email from PHP"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.