Reputation: 7693
I have a simple test.php
file which says:
if (mail('[email protected]', 'test mail', 'test mail test')){
echo 'ok';
}
else{
echo 'bad';
}
When I execute this file in CLI with php5 -f test.php
, the file's output is ok
, I receive the e-mail properly and /var/log/mail.log
gets lines written to it.
However, when I execute this file from apache2's virtualhost (from web, by loading it), it also says ok
, but no log is created and I don't receive the e-mail (it's not in the SPAM folder either).
Any idea what may I be doing wrong?
One idea that comes to my mind is that in CLI I'm executing it as user X
, while in virtualhost I believe I'm executing it as www-data
user. However, I don't know where to check if there is any such limitation to postfix.
Any ideas?
EDIT
I tested it as www-data
in CLI and it does work for this user in CLI.
sudo su www-data
php5 -f test.php
Upvotes: 0
Views: 79
Reputation: 2129
Did you check your php.ini?
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
http://www.quackit.com/php/tutorial/php_mail_configuration.cfm
Upvotes: 2