in php.ini you should set
sendmail_from = me@example.com
Main Topics
Browse All TopicsI'm getting "Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in... "
on this code:
<?php
$to = "test@test.com";
$body = "Type: ".$_POST["type"]."\nMessag
if (mail($to,"Contact",$body)
echo("<p>Message sent!</p>");
}
else{
echo("<p>Message delivery failed...</p>");
}
?>
Why is this happening? I'm not using any extra headers...
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
No good. I also copy pasted the following ode from the PHP manual, and it gave me the same error. I can't edit the php.ini file on the public server that'll be hosting the page. Any thoughts?
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
echo("Success");
else
echo("failure");
?>
I had the same problem on my server. Quickest solution is to download PHPMailer (http://phpmailer.sourcefo
M
I am currently with HostVector (http://www.hostvector.com
M
Just to clear something up: phpMailer doesn't necessarily need an SMTP server. By default, it acts as a front end to mail(), so it uses whatever mailer is available on your system (sendmail, or others via sendmail wrappers, qmail-inject etc). On Windows servers there often isn't one, so you can use IsSMTP() and talk to one elsewhere (not necessarily at the same ISP). Most people having trouble with mail() are in fact having trouble getting message formatting right, and this is something that phpMailer makes very easy. There are really no downsides to using PHPMailer.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Split: quad341 & krakilin2001
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
Huji
EE Cleanup Volunteer
Business Accounts
Answer for Membership
by: quad341Posted on 2005-07-12 at 10:46:16ID: 14423844
on windows or on certain mail servers, you have to specify a "From:" header to allow the message to send. the php.ini does not have a default one, so you must specify it.
$header)){
you need to add an extra header for from like the following
$header = "From: me@example.com"; // use whatever from you want
// like your original code
if (mail($to,"Contact",$body,
echo("<p>Message sent!</p>");
}
else{
echo("<p>Message delivery failed...</p>");
}