Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The mail() function in php works strange these days.

<?php
mail("email@mail.com", "Subject", "Content");
?>

The above script works if I use "php script.php" in command line. However, if I link to the page(http://domain.com/script.php) by browser, the mail will not be sent even if the mail function returns true.

I googled about it and find a solution. It says "modify the php.ini file as following".

Change

sendmail_path = "/usr/sbin/sendmail -t -i"

to

sendmail_path = "/usr/sbin/sendmail -t"

And it works for me right now. Does anyone know why removing parameter -i can solve the problem? it goes well with -i in the past few months!!

share|improve this question

1 Answer 1

From the sendmail manual page:

-i Ignore dots alone on lines by themselves in incoming messages. This should be set if you are reading data from a file.

So it may depend on how the content is formatted, or how mail() internally decides to read the content and then feed it to sendmail (were previous versions of mail() writing the content string in a temporary file and then calling sendmail?).

share|improve this answer
    
I'm curious about why typing in the command(php script.php) is different from retrieve from apache(domain.com/script.php). –  benck Sep 26 '11 at 6:00
    
When you issue -i, sendmail waits for end-of-file. –  adamo Sep 26 '11 at 6:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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