Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailcatcher: PHP mail() function returns false

i will try to describe my problem:

to debug outgoing email in local environment i installed mailcatcher (http://mailcatcher.me/) but faced some problems with catching mails sent from web. if i run the script which contains only one mail() call, everything is fine and i can see the sent email in mailcatcher 127.0.0.1:1080. But when i try to access the same script from the web browser, the mail() function returns false, no any error displayed in browser, nothing in error logs. In mail log even i can see the call for mail() function.

i am not sure, may be my nginx/php-fpm configuration is wrong, or something wrong with permissions.

selinux is disabled.

please help if you know the solution.

Thanks in advance

like image 998
user1112057 Avatar asked Jul 14 '14 16:07

user1112057


2 Answers

I faced the same problem on ubuntu 14.04.

/etc/php5/cli/php.ini and /etc/php5/fpm/php.ini had the same sendmail_path configuration but only php-cli could send emails.

For my environment, Mailcatcher works on a distant server and I use the catchmail command to contact it.

Here is the sendmail_path I used:

sendmail_path = /usr/bin/env catchmail --smtp-ip mailcatcher-ip -f [email protected]

For the fpm php.ini file, I had to specify the full path to catchmail for the mail function to work correctly:

sendmail_path = /usr/bin/env /usr/local/bin/catchmail --smtp-ip mailcatcher -f [email protected]
like image 96
Alexis N-o Avatar answered Sep 19 '22 02:09

Alexis N-o


If you use Mac OS Sierra or later:
here is the right place of catchmail:

change sendmail_path = /usr/bin/env catchmail -f [email protected]
By sendmail_path = /usr/local/bin/catchmail -f [email protected].

like image 33
berramou Avatar answered Sep 21 '22 02:09

berramou