PHP mail doesn't work - www-data cannot run sendmail?

Discussion in 'Installation/Configuration' started by Keen Mouse, Oct 3, 2018.

  1. Keen Mouse

    Keen Mouse New Member

    I have done a multi-server installation of ISPConfig 3 without mail services installed on the Nginx web server. I have installed sendmail, but my sites can't send mail using PHP mail. I tried logging in as www-data to diagnose this and found that there is no sendmail in www-data's /usr/sbin, I assume because www-data is chrooted? I'm not sure how to fix this.
     
  2. Jesse Norell

    Jesse Norell Well-Known Member

    What error do you get? Look both in the web server/php logs as well as mail.log.

    I don't use nginx, but I believe it only supports php via fastcgi (eg. php-fpm), so your php processes should be running as the website user, not as www-data.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig does not supports endmail. But using postfix instead even without configuring mail services in ISPConfig works fine for that purpose, see web node setup in ISPConfig Multiserver tutorials.
     
  4. Keen Mouse

    Keen Mouse New Member

    I'm following Multiserver Setup With Dedicated Web, Email, DNS & MySQL Database Servers On Debian Squeeze With ISPConfig 3 and the only mention of Postfix is on the mail server setup page.

    I was originally trying to use SSMTP, and found out yesterday how to override the default PHP sendmail_path, but still couldn't get it working, probably for the same reason I can't get sendmail working now. I thought I would try sendmail, since that's what sendmail_path is set for by default.

    When you say ISPConfig doesn't support sendmail, do you mean for sending its own messages? Because I am getting emails from ISPConfig itself without any trouble, whether I use SSMTP or sendmail. I assume it's not using the PHP mail function, which is what I am concerned with, because I want to use it on my sites. Is that what Postfix is supposed to fix? If I install Postfix, will sendmail_path be set to support it, or will I have to manually override it like I was trying to do for SSMTP?
     
  5. Keen Mouse

    Keen Mouse New Member

    I'm not seeing errors in any logs (web server, website, PHP, mail), which is making it difficult to troubleshoot. I only see "Could not start mail function" in the Joomla admin interface.

    I didn't know that about php-fpm. You're right, I see that it is running as the website user, "web4" in this case. When I su as web4, there is no /usr/sbin/sendmail either, which I assume is the problem.
     
  6. Keen Mouse

    Keen Mouse New Member

    I have run the minimal Postfix install from page 26 of the ISPConfig 3.1 manual and then update.php, which detected and configured Postfix. None of this makes any difference to PHP sendmail_path, which always defaults to "/usr/sbin/sendmail -t -i -f [email protected][mydomain]", and it doesn't put postfix where the website user can access it anyway, just like ssmtp and sendmail weren't. I don't see how ISPConfig supports using the PHP mail function at all.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    That's not for sendmail, it's for postfix. Postfix contains a program called 'sendmail', it is a sendmail style wrapper used by shell scripts and also php mail function.

    Sendmail path does not need to be changed, its is correct as it is and php mail() function works fine by default on all setup guides that we published, no changes required. /usr/sbin/sendmail does not need to put inside a website to make it reachable for PHP, it simply has to exist in the path /usr/sbin/sendmail of the system. So to test if the Postfix sendmail binary is there, login as root user to your server and run:

    ls -la /usr/sbin/sendmail

    the result should be similar to:

    [email protected]:/# ls -la /usr/sbin/sendmail
    -rwxr-xr-x 1 root root 26680 Apr 29 2017 /usr/sbin/sendmail

    When you change things of course or install other software like installing other smtp servers or ssmtp, then it's likely thtat the setup breaks and emails ending will stop. even when you reinstall postfix later.

    You might have wanted to post the real error message in the first post. This message pops up in Joomla when something in the Joomla mail settings is set wrong or when you disabled the php mail() function in PHP. That's not about an ispconfig sendmail path setting.

    Which settings have you chosen in Joomla under Site -> Global Configuration -> Server -> Mail Settings? Please post a screenshot.
     
    Keen Mouse likes this.
  8. Keen Mouse

    Keen Mouse New Member

    Sorry for my lack of understanding and unfounded assumptions.

    I have postfix installed now and Joomla is no longer giving me an error. But I am getting the following in /var/log/mail.log:

    Code:
    Oct  5 19:42:14 [hostname] postfix/pickup[4324]: 4F3C243EA5: uid=1003 from=<[email protected][mydomain]>
    Oct  5 19:42:14 [hostname] postfix/proxymap[5038]: warning: mysql:/etc/postfix/mysql-virtual_outgoing_bcc.cf is unavailable. unsupported dictionary
     type: mysql
    Oct  5 19:42:14 [hostname] postfix/cleanup[5037]: warning: proxy:mysql:/etc/postfix/mysql-virtual_outgoing_bcc.cf lookup error for "[email protected]
    .com"
    Oct  5 19:42:14 [hostname] postfix/cleanup[5037]: warning: 4F3C243EA5: sender_bcc_maps map lookup problem -- message not accepted, try again later
    Oct  5 19:42:14 [hostname] postfix/pickup[4324]: warning: maildrop/7A4D343E74: error writing 4F3C243EA5: queue file write error
    Oct  5 19:42:14 [hostname] postfix/pickup[4324]: 5102843EA5: uid=1003 from=<[email protected][mydomain]>
    Oct  5 19:42:14 [hostname] postfix/proxymap[5038]: warning: mysql:/etc/postfix/mysql-virtual_outgoing_bcc.cf is unavailable. unsupported dictionary
     type: mysql
    Oct  5 19:42:14 [hostname] postfix/cleanup[13179]: warning: proxy:mysql:/etc/postfix/mysql-virtual_outgoing_bcc.cf lookup error for "[email protected]
    mouse.com"
    Oct  5 19:42:14 [hostname] postfix/cleanup[13179]: warning: 5102843EA5: sender_bcc_maps map lookup problem -- message not accepted, try again later
    Oct  5 19:42:14 [hostname] postfix/pickup[4324]: warning: maildrop/688E343E7D: error writing 5102843EA5: queue file write error
    
    Does this have something to do with my trying ssmtp and sendmail and uninstalling/reinstalling postfix while testing? Would it be easier to fix as it is now, or should I start over somewhere?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Please install the postfix-mysql package too.
     
    Keen Mouse likes this.
  10. Keen Mouse

    Keen Mouse New Member

    Problem solved. Thank you!
     

Share This Page