Mailcatcher: PHP mail () function returns false

I will try to describe my problem:

To debug outgoing e-mail in a local environment, I installed mailcatcher ( http://mailcatcher.me/ ), but ran into some problems with finding emails sent from the Internet. if I run a script that contains only one call to mail (), everything is fine, and I can see the sent message in mailcatcher 127.0.0.1:1080. But when I try to access the same script from a web browser, the mail () function returns false, no error is displayed in the browser, nothing is displayed in the error logs. In the mail log, even I see a call to the mail () function.

I'm not sure, maybe my nginx / php-fpm configuration is wrong or something is wrong with permissions.

selinux is disabled.

please help if you know the solution.

Thank you in advance

+6
source share
3 answers

I ran into the same issue 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 email messages.

In my environment, Mailcatcher runs on a remote 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 address@example.com 

For the fpm php.ini I needed 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 address@example.com 
+5
source

With php-fpm, it works neatly with the supplied shell script RVM (?).

 sendmail_path = /usr/local/rvm/wrappers/default/catchmail 
+2
source

On CentOS 7 using PHP-FPM with PHP 5.6, I found that I had to change /etc/php-fpm.d/www.conf instead of adding ini files to /etc/php.d or changing /etc/php.ini . It also required a full path, as in @Alexis No.'s answer

 php_admin_value[sendmail_path] = '/usr/bin/env GEM_PATH=/usr/share/gems:/usr/local/share/gems:/usr/share/rubygems:$HOME/.gem/ruby /usr/local/bin/catchmail --smtp-ip 127.0.0.1 --smtp-port 1025 -f mailcatcher@example.com ' 

Update: I recently discovered that GEM_PATH is zero when running php-fpm as apache in some environments. No matter what I tried (/ etc / gemrc), I couldn't do it otherwise than embed GEM_PATH as part of this command.

0
source

Source: https://habr.com/ru/post/972187/


All Articles