Jump to content

Please help with mail php code


damick11

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.