PHP Mail() for local mail fails

Discussion in 'Installation/Configuration' started by vincentthe, Nov 16, 2006.

  1. vincentthe

    vincentthe New Member


    I ran into a strange problem yesterday. I am totally unable to get mail generated via the php-mail command to be delivered on any local e-mail address on the same server. The mail addresses work perfectly when mail from the outside is sent to them, and the php mail function also works smooth when sending mail "to the outside".

    So an e-mail form on can't send mail to [email protected] or [email protected] (which resides on the same server) but it can send to [email protected] which runs at another server. [email protected] and [email protected] can receive mail send via other ways (hotmail,gmail, outlook).

    Any suggestions would be appreciated.
  2. vincentthe

    vincentthe New Member

    What I forgot to state, the mail() function doesn't give any errors...
  3. Ben

    Ben ISPConfig Developer ISPConfig Developer

    could you show the output of the mail logfile while sending that mailcommand please?

    mail() normally returns TRUE or FALSE only.
  4. vincentthe

    vincentthe New Member

    in this case mail() always returns true somehow.

    Which file should I look for?
    /var/log/mail.log mail.err don't show any signs of having entry's written to them (other then imap/courier messages of login/logout).
  5. fobicodam

    fobicodam ISPConfig Developer ISPConfig Developer

    I had a similar problem yesterday and take me 2 hour to realize the problem...

    PHP uses sendmail to send mail, and it was not installed on my server.

    Somehow the postfix's sendmail doesnt work 100% compatible, so i had to modify the php.ini. Where it says "/usr/sbin/sendmail -t -i" put "/usr/sbin/sendmail.postfix -t -i"

    Maybe your sendmail is still running and delivering to external servers, but it doesnt work with local domains.
  6. vincentthe

    vincentthe New Member

    This seems to be the right direction only /etc/sbin/sendmail.postfix will result in mail() returning false. Both "/etc/sbin/sendmail.postfix -t -i" and "/etc/sbin/postfix -t -i" fail. The postfix executable is in /etc/sbin
  7. fobicodam

    fobicodam ISPConfig Developer ISPConfig Developer

    It worked for me, the mail has "apache" as sender but ill check how to change it.
  8. vincentthe

    vincentthe New Member

    Is /etc/sbin/sendmail.postfix a symlink on your system? It doesn't exist on my system (Ubuntu 6.06 LTS)
  9. fobicodam

    fobicodam ISPConfig Developer ISPConfig Developer

    No, its not.. i have no access to my servers right now
  10. vincentthe

    vincentthe New Member

    Ok, this is not the problem. /etc/sbin/sendmail actually is the postfix sendmail wrapper. Sendmail has never been installed on this server...

    Any other suggestions?
  11. falko

    falko Super Moderator ISPConfig Developer

    Are there any errors in your mail log? Do you use Maildir or mbox? What's the output of
    netstat -tap
    Are the domains you're sending to listed in /etc/postfix/local-host-names?
  12. vincentthe

    vincentthe New Member

    [email protected]:/home/vincentthe# netstat -tap
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 *:mysql *:* LISTEN 3975/mysqld
    tcp 0 0 *:81 *:* LISTEN 4319/ispconfig_http
    tcp 0 0 vincent-1.adsl.ut:61825 SYN_RECV -
    tcp 0 0 *:* LISTEN 4554/named
    tcp 0 0 *:* LISTEN 4554/named
    tcp 0 0 localhost:domain *:* LISTEN 4554/named
    tcp 0 0 *:smtp *:* LISTEN 12948/master
    tcp 0 0 localhost:953 *:* LISTEN 4554/named
    tcp6 0 0 *:imaps *:* LISTEN 3849/couriertcpd
    tcp6 0 0 *:pop3s *:* LISTEN 3884/couriertcpd
    tcp6 0 0 *:pop3 *:* LISTEN 3864/couriertcpd
    tcp6 0 0 *:imap2 *:* LISTEN 3829/couriertcpd
    tcp6 0 0 *:www *:* LISTEN 4581/apache2
    tcp6 0 0 *:ftp *:* LISTEN 12851/proftpd: (acc
    tcp6 0 0 *:ssh *:* LISTEN 4138/sshd
    tcp6 0 0 *:smtp *:* LISTEN 12948/master
    tcp6 0 0 ip6-localhost:953 *:* LISTEN 4554/named
    tcp6 0 0 *:https *:* LISTEN 4581/apache2
    tcp6 0 1332 vincent-1.adsl.ut:61827 ESTABLISHED24488/sshd: vincent

    No errors found in the mail log, I'm using Maildir and and yes the domains are listed in /etc/postfix/local-host-names
  13. falko

    falko Super Moderator ISPConfig Developer

    Please run
    tail -f /var/log/mail.log
    and then send a mail to a local account with PHP's mail() function. Do you see any action then in the tail output?

Share This Page