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 = '[email protected]'; 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 Link to comment https://forums.phpfreaks.com/topic/58388-email-script/ 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 = "[email protected]"; $subject = "The subject of the e-mail goes here"; $headers = "From: [email protected]\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 Link to comment https://forums.phpfreaks.com/topic/58388-email-script/#findComment-289503 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"; Link to comment https://forums.phpfreaks.com/topic/58388-email-script/#findComment-289510 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. Link to comment https://forums.phpfreaks.com/topic/58388-email-script/#findComment-289674 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 Link to comment https://forums.phpfreaks.com/topic/58388-email-script/#findComment-289701 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 = '[email protected]'; mail($to, "Test email from PHP", "Test email from PHP"); Link to comment https://forums.phpfreaks.com/topic/58388-email-script/#findComment-289708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.