problms with "From" in php email form

I have built a web form that send to my email from another email in my system, mail goes through just fine, however, the From header in the received email shows my server address instead of the proper from address. Here is the script.

[php]
ini_set(“sendmail_from”,"[email protected]");

$subject = 'Device Purchase Alert: ‘.$_POST[‘manufacturer’].’ ‘.$_POST[‘model’];
$message = ‘Hello, ‘.$_POST[‘name’].’ has received a ‘.$_POST[‘manufacturer’].’ ‘.$_POST[‘model’].’ for ‘.$_POST[‘carrier’].’ in ‘.$_POST[‘condition’].’ condition. This item was a ‘.$_POST[‘type’].’ for the amount of $’.$_POST[‘amount’].’. The ESN/MEID of this device is ‘.$_POST[‘meid’].’.

Comments: '.$_POST[‘comments’].‘



This email is intended for employees and management of Gomo Wireless. If you are not one of these people, please delete this email immediately. Thank you’;

$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
$headers .= ‘From: Purchasing’ . “\r\n”;
$headers .= ‘From: [email protected]’ . “\r\n”;
$headers .= ‘X-Mailer: PHP/’ . phpversion();

mail("[email protected]", $subject, $message, $headers, “-f [email protected]”);

[/php]

not sure what I am doing wrong.

Simple Mailer
[php]<?php
// Some data for the message
$mailTo = "[email protected]";
$mailFrom = "[email protected]";
$mailFromName = “Some One”;
$mailSubject = “Your Subject”;
$mailMessage = “Your message.”;

// Send mail
mail($mailTo, $mailSubject, $mailMessage, “From: $mailFromName <$mailFrom>\r\n”);
?>[/php]

More Complex Mailer
[php]<?php
// Recipients
$mailTo = "[email protected], [email protected]"; // note the comma

// Copies
$mailCc = "[email protected]";
$mailBcc = "[email protected]";

// From
$mailFrom = "[email protected]";
$mailFromName = “Some One”;

// Reply address
$mailReplyTo = "[email protected]";

// Message subject and contents
$mailSubject = “Your Subject”;
$mailMessage = “Your message.\n\nYour Signature”;

// Text message charset
$mailCharset = “windows-1252”; // must be accurate (e.g. “Windows - 1252” is invalid)

// Create headers for mail() function
$headers = “Content-type: text/html; charset=$mailCharset\r\n”;
$headers .= “From: $mailFromName <$mailFrom>\r\n”;
$headers .= “Reply-To: $mailReplyTo\r\n”;
$headers .= “Cc: $mailCc\r\n”;
$headers .= “Bcc: $mailBcc\r\n”;

// Send mail
mail($mailTo, $mailSubject, $mailMessage, $headers);
?>[/php]

And the answer to the question is your header is wrong. You don’t need to Froms in there.

$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
$headers .= ‘From: Purchasing <[email protected]’ . “\r\n”;
$headers .= ‘X-Mailer: PHP/’ . phpversion();

also don’t need that -f stuff at the end, its already contained in the header.

Sponsor our Newsletter | Privacy Policy | Terms of Service