0

I'm working on a php script which has to send emails. But my mail() function doesn't work. I know that I have to configure somehow php.ini and may be something else but I don't know what exactly and how. I installed sendmail, by the way. Any ideas? Thanks a lot. this is my code.

error_reporting(E_ALL); 

$to  = '[email protected]';

$subject = 'subject';

$message = 'text';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
$headers .= 'To: user <[email protected]>' . "\r\n";
$headers .= 'From: server <[email protected]>' . "\r\n";

mail($to, $subject, $message, $headers);

in php.ini i put sendmail_path ="/usr/sbin/sendmail"

ps. i Use Ubuntu

guys, in the mail.log file i got

Apr 29 16:12:05 IT02 sendmail[7660]: My unqualified host name (IT02) unknown; sleeping    for retry 
Apr 29 16:13:05 IT02 sendmail[7660]: unable to qualify my own domain name (IT02) -- using short name 
Apr 29 16:13:05 IT02 sendmail[7660]: p3TED551007660: from=www-data, size=210, class=0, nrcpts=0, msgid=<201104291413.p3TED551007660@IT02>, bodytype=8BITMIME, relay=www-data@localhost 

Does anybody know what it means?

6
  • show some code or atleast say what error u get. And which OS are you using Linux or Windows???
    – jimy
    Apr 29, 2011 at 13:13
  • @Kuen, for information your question is not so clear. No, one can understand this and answer you. Improve the Description given. Apr 29, 2011 at 13:13
  • 3
    it could be supposed that the server is linux and the directive to configure is the one relative to sendmail Apr 29, 2011 at 13:16
  • sorry, guys, my bad. I use ubuntu,
    – Kuen
    Apr 29, 2011 at 13:50
  • @Kuen, edit your original post with that code and information. It isn't readable as a comment.
    – Brad
    Apr 29, 2011 at 13:52

1 Answer 1

6

The first step would be to figure out where sendmail is installed. Once you know that path, go into your php.ini. You are looking for the sendmail_path setting. Set it appropriately.

If the path is set correctly, the result from a proper call to mail() should return true. (Note that the return value only lets you know if the message was passed on to sendmail [or SMTP in the case of Windows]. It does not guarantee that the e-mail went out, or that sendmail is configured correctly.) If it is returning true and you still aren't getting e-mail, then check your sendmail configuration.

2
  • sendmail is installed. in the mail.log i got: Apr 29 16:12:05 IT02 sendmail[7660]: My unqualified host name (IT02) unknown; sleeping for retry Apr 29 16:13:05 IT02 sendmail[7660]: unable to qualify my own domain name (IT02) -- using short name Apr 29 16:13:05 IT02 sendmail[7660]: p3TED551007660: from=www-data, size=210, class=0, nrcpts=0, msgid=<201104291413.p3TED551007660@IT02>, bodytype=8BITMIME, relay=www-data@localhost
    – Kuen
    Apr 29, 2011 at 14:14
  • So, your problem has nothing to do with PHP at all. Not to mention, this is an extremely common issue. fedoraforum.org/forum/archive/index.php/t-85365.html
    – Brad
    Apr 29, 2011 at 14:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.