Link to home
Start Free TrialLog in
Avatar of rivkamak
rivkamakFlag for United States of America

asked on

php mail not nice FROM

I'm trying to set up a PHP Mail to send using a nice FROM email address.
I think I coded it correctly but it's not working. I'm still getting the default server email
  mail( $email,"Thanks for choosing Donatecar.TV", $bodyDonor ,  "From: DonateCar.TV <donatecarcs@***.com>\n" . 
    "MIME-Version: 1.0\n" . 
    "Content-type: text/html; charset=iso-8859-1"); 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rivkamak

ASKER

Can it be something not set up properly in the PHP.INI file?
Not likely if it is sending mail at all.
Ummm.... Many things wrong with your code. Do this:

$subject = "Thanks for choosing Donatecar.TV";

// To send HTML mail, the Content-type header must be set
$headers   = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: DonateCar.TV <donatecarcs@***.com>";
$headers[] = "Reply-To: DonateCar.TV <donatecarcs@***.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();

// Mail it
mail($email, $subject, $bodyDonor, implode("\r\n", $headers));
By the by, the reason it didn't work is most likely because of your line endings. If you happened to connect with a Windows machine anywhere in route, the commands would've failed and errored. It's probably in a log file on the system if you care.

Try using the easy method in the future, since I don't think gmail will accept these with the way it's written...

PHPMailer http://phpmailer.worxware.com/