damick11 Posted March 2, 2010 Share Posted March 2, 2010 I purchased a template, which already had php mail code in it, and all I had to do was replace my email address with their placemarked email address and it worked just fine, no issues at all. A friend of mine did the same, recieved the same email php code, but theirs WILL not work. They are using a different hosting service (yahoo), but other than that, I can not figure this out and have tried modifying the code in various ways to no avail. We called yahoo, and they uploaded a test php mail code that worked just fine as a test, but it did not count for the mail form, so when we went to incorporate it, it would send an email, but only with the title of the email, no customer content (name, phone number, email address, and the customer's message. Here is the original code: <? $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $message=$_POST['message']; $ToEmail = "[email protected]"; $ToSubject = "Message from website.com"; $EmailBody = "Name: $name\n Email: $email\n Phone: $phone\n Message: $message\n"; $Message = $EmailBody; $headers .= "Content-type: text; charset=iso-8859-1\r\n"; $headers .= "From:".$name." / ".$email."\r\n"; mail($ToEmail,$ToSubject,$Message, $headers); ?> and here is the code provided by yahoo as a test: <?php $email = '[email protected]'; $subject = 'Yahoo! Customer Care mail Function Test'; $message = 'This message is a test to make sure your mail forms are working OK.'; $headers = "MIME-Version: 1.0rn"; $headers.= "Content-type: text/html; charset=iso-8859-1rn"; $headers.= "X-Nyar-Nyar: Test header to test withrn"; if (mail($email,$subject,$message,$headers)) { echo "Success! Whatever else doesn't work, it ain't PHP. This mail has been sent to the MTA"; } else { echo "An error has occurred: email to $email has failed."; } ?> Please help me figure out why the first code will not work, even though I am using it with no issues. Link to comment https://forums.phpfreaks.com/topic/193926-please-help-with-mail-php-code/ Share on other sites More sharing options...
ferdi Posted March 2, 2010 Share Posted March 2, 2010 The only thing I can see different from your's to Yahoo's example, is that they don't use slashes to define new lines. This is rather... unusual. But try it that way, it could just work. Link to comment https://forums.phpfreaks.com/topic/193926-please-help-with-mail-php-code/#findComment-1020550 Share on other sites More sharing options...
damick11 Posted March 2, 2010 Author Share Posted March 2, 2010 Would you believe it...that was it!!! Thanks so much! Link to comment https://forums.phpfreaks.com/topic/193926-please-help-with-mail-php-code/#findComment-1020557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.