Search code examples
xamppphpmailerphp-7

Can't force phpMailer to send mail from nginx server


I use actual version of phpMailer (downloaded yesterday from github). It sends mails from my local computer (Win10, xampp 7.4.3) and can't send it from server (centOs7, nginx, php7). Both computers in one LAN behind the same firewall. I suspect php.ini configuration, but what should be configured exactly?

Thanks for any help.


Solution

  • The solution:

    # sudo setsebool -P httpd_can_sendmail 1
    

    The tracking of my search:

    1. Switch on the DebugMode in phpMailer (for each new PHPMailer object):
    $mail = new PHPMailer\PHPMailer\PHPMailer();
    $mail->SMTPDebug = 4;
    
    1. Checking out 'Console' tab output in Chrome DevTools:
    SMTP ERROR: Failed to connect to server: Permission denied (13)
    
    1. Googling for the error text - https://stackoverflow.com/a/50302148/9751142

    Hope this helps anybody else.