Page 1 of 1

what is wrong with this mail delivery?????

Posted: Sat Jan 10, 2009 2:59 am
by finkel
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>


when i run it , it give me this notice :
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in c:\wamp\www\try.php on line 7
Mail Sent.

Re: what is wrong with this mail delivery?????

Posted: Sat Jan 10, 2009 4:24 am
by requinix
I don't see anything wrong.

Then again, I don't see anything except for a small block of code. No description, no explanation, no clarification, nothing that you, as somebody asking a question, should provide.

We'll put just as much effort into answering your questions as you put into asking them.

Re: what is wrong with this mail delivery?????

Posted: Sat Jan 10, 2009 5:02 am
by finkel
when i run it it gives me this notice : "Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in c:\wamp\www\try.php on line 7
Mail Sent."

Re: what is wrong with this mail delivery?????

Posted: Sat Jan 10, 2009 6:01 am
by requinix
It means PHP isn't set up to send emails from your computer. It doesn't know what mail server it should talk to.

If you're just testing code or learning PHP, ignore that message. On a real web host there won't be any problems.

Re: what is wrong with this mail delivery?????

Posted: Sun Jan 25, 2009 8:04 am
by mstefaniak
I am having a similar problem on my system. I put the most basic code in, but I get no mail, and no errors. I am very new with sendmail/unix administration so I don't know if there is a log or something I can use to troubleshoot the error.

The mailer is supposed to be a 3rd party message broker, the user will supply their e-mail address, and the form will e-mail it to the intended party.

My php code

Code: Select all

 
<?php
ini_set('sendmail_from', 'mailer@helpme.com');
$to      = 'someone@helpme.com';
$subject = 'the subject';
$message = 'the message';
 
mail($to,$subject,$message); 
 
?>
 
The above code (except for line 3) was 100% the basic code in the php mail function on http://www.php.net. I added line 3 because my php.ini file does not have a default From address