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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
finkel
Forum Newbie
Posts: 6
Joined: Sat Jan 10, 2009 2:57 am

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

Post 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.
Last edited by finkel on Sat Jan 10, 2009 4:59 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
finkel
Forum Newbie
Posts: 6
Joined: Sat Jan 10, 2009 2:57 am

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

Post 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."
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
mstefaniak
Forum Newbie
Posts: 1
Joined: Sun Jan 25, 2009 7:53 am

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

Post 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
Post Reply