Why doesnt my server send emails with postfix from php?

  • After a fresh install of Debian 6 minimal and i-mscp, I've transitioned my sites to this server.


    While trying a php form to send email, I found that my server was not sending out any email. Wordpress notifications werent being received.


    I tried the following command in bash:


    Code
    1. echo "this is the body" | mail -s "this is the subject" "[email protected]"


    And found this log:

    Code
    1. [root@hermes] /etc #tail -n 30 /var/log/mail.infoMay 24 23:36:37 hermes postgrey[4086]: 2013/05/24-23:36:37 postgrey (type Net::Server::Multiplex) starting! pid(4086)May 24 23:36:37 hermes postgrey[4086]: Binding to TCP port 10023 on host localhost#012May 24 23:36:37 hermes postgrey[685]: 2013/05/24-23:36:37 Server closing!May 24 23:36:37 hermes postgrey[685]: Couldn't unlink "/var/run/postgrey.pid" [Permission denied]May 24 23:36:38 hermes postfix/policyd-weight[562]: master: /etc/policyd-weight.conf reloadedMay 24 23:36:39 hermes postfix/policyd-weight[563]: cache: /etc/policyd-weight.conf reloadedMay 24 23:36:40 hermes postfix/master[975]: terminating on signal 15May 24 23:36:40 hermes postfix/master[4185]: daemon started -- version 2.7.1, configuration /etc/postfixMay 24 23:37:55 hermes postfix/pickup[4192]: B7272404180A: uid=0 from=<root>May 24 23:37:55 hermes postfix/cleanup[4310]: B7272404180A: message-id=<[email protected]>May 24 23:37:55 hermes postfix/qmgr[4193]: B7272404180A: from=<[email protected]>, size=457, nrcpt=1 (queue active)May 24 23:37:55 hermes postfix/virtual[4312]: B7272404180A: to=<[email protected]>, relay=virtual, delay=0.02, delays=0.02/0/0/0, dsn=5.1.1, status=bounced (unknown user: "[email protected]")May 24 23:37:55 hermes postfix/cleanup[4310]: BA5A2404180B: message-id=<[email protected]>May 24 23:37:55 hermes postfix/bounce[4313]: B7272404180A: sender non-delivery notification: BA5A2404180BMay 24 23:37:55 hermes postfix/qmgr[4193]: BA5A2404180B: from=<>, size=2218, nrcpt=1 (queue active)May 24 23:37:55 hermes postfix/qmgr[4193]: B7272404180A: removedMay 24 23:37:55 hermes postfix/local[4314]: BA5A2404180B: to=<[email protected]>, relay=local, delay=0.04, delays=0/0/0/0.04, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")May 24 23:37:55 hermes postfix/qmgr[4193]: BA5A2404180B: removedMay 24 23:53:04 hermes postfix/master[4185]: terminating on signal 15May 24 23:53:04 hermes postfix/master[4453]: daemon started -- version 2.7.1, configuration /etc/postfixMay 24 23:53:13 hermes postfix/pickup[4459]: 5E87C404180B: uid=0 from=<root>May 24 23:53:13 hermes postfix/cleanup[4465]: 5E87C404180B: message-id=<[email protected]>May 24 23:53:13 hermes postfix/qmgr[4460]: 5E87C404180B: from=<[email protected]>, size=457, nrcpt=1 (queue active)May 24 23:53:13 hermes postfix/virtual[4467]: 5E87C404180B: to=<[email protected]>, relay=virtual, delay=0.03, delays=0.02/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "[email protected]")May 24 23:53:13 hermes postfix/cleanup[4465]: 62DE1404180C: message-id=<[email protected]>May 24 23:53:13 hermes postfix/qmgr[4460]: 62DE1404180C: from=<>, size=2218, nrcpt=1 (queue active)May 24 23:53:13 hermes postfix/bounce[4468]: 5E87C404180B: sender non-delivery notification: 62DE1404180CMay 24 23:53:13 hermes postfix/qmgr[4460]: 5E87C404180B: removedMay 24 23:53:13 hermes postfix/local[4469]: 62DE1404180C: to=<[email protected]>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")May 24 23:53:13 hermes postfix/qmgr[4460]: 62DE1404180C: removed


    My postfix conf:


    How can I check what's wrong?

    Edited once, last by dzchimp ().


  • Thanks. The postgrey error was fixed by the bugfix.


    However how do I go about fixing the bounce due to unknown user issue?


    Latest log:

    Code
    1. #cat /var/log/mail.infoMay 25 08:35:50 hermes authdaemond: modules="authuserdb authpam", daemons=5May 25 08:35:50 hermes authdaemond: Installing libauthuserdbMay 25 08:35:50 hermes authdaemond: Installation complete: authuserdbMay 25 08:35:50 hermes authdaemond: Installing libauthpamMay 25 08:35:50 hermes authdaemond: Installation complete: authpamMay 25 08:35:50 hermes postfix/policyd-weight[676]: policyd-weight 0.1.15 devel-1 started and daemonized. conf:/etc/policyd-weight.conf; GID:110 110 EGID:110 110 UID:106 EUID:106; taint mode: 1May 25 08:35:50 hermes postfix/policyd-weight[676]: warning: cache_query: $csock couln't be created: connect: No such file or directory, calling spawn_cache()May 25 08:35:50 hermes postfix/policyd-weight[678]: cache spawnedMay 25 08:35:50 hermes postgrey[677]: Process BackgroundedMay 25 08:35:50 hermes postgrey[677]: 2013/05/25-08:35:50 postgrey (type Net::Server::Multiplex) starting! pid(677)May 25 08:35:50 hermes postgrey[677]: Binding to TCP port 10023 on host localhost#012May 25 08:35:50 hermes postgrey[677]: Setting gid to "111 111"May 25 08:35:50 hermes postgrey[677]: Setting uid to "107"May 25 08:35:51 hermes postfix/master[936]: daemon started -- version 2.7.1, configuration /etc/postfixMay 25 08:36:50 hermes postfix/pickup[942]: C52344041803: uid=0 from=<root>May 25 08:36:50 hermes postfix/cleanup[1481]: C52344041803: message-id=<[email protected]>May 25 08:36:50 hermes postfix/qmgr[943]: C52344041803: from=<[email protected]>, size=457, nrcpt=1 (queue active)May 25 08:36:50 hermes postfix/virtual[1483]: C52344041803: to=<[email protected]>, relay=virtual, delay=0.02, delays=0.01/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "[email protected]")May 25 08:36:50 hermes postfix/cleanup[1481]: C9C414041809: message-id=<[email protected]>May 25 08:36:50 hermes postfix/qmgr[943]: C9C414041809: from=<>, size=2218, nrcpt=1 (queue active)May 25 08:36:50 hermes postfix/bounce[1484]: C52344041803: sender non-delivery notification: C9C414041809May 25 08:36:50 hermes postfix/qmgr[943]: C52344041803: removedMay 25 08:36:50 hermes postfix/local[1485]: C9C414041809: to=<[email protected]>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")May 25 08:36:50 hermes postfix/qmgr[943]: C9C414041809: removed


    Some more details of my config:

    Edited once, last by dzchimp ().

  • Hello


    The MTA sendmail shouldn't be installed with i-MSCP. Postfix is providing sendmail command.


    http://www.postfix.org/sendmail.1.html


    Thank you for using i-MSCP

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Hi Nuxwin, I still have this issue where if the MTA sendmail is not installed, the following function in php does not work:


    `@mail($email_to, $email_subject, $email_message, $headers);`


    No emails are sent by php. The only solution so far was installing sendmail. That of course removes postfix automatically. I'd like to get to the bottom of this.


    Latest logs after purging sendmail and installing i-mscp over the installation:


    Code
    1. #tac /var/log/mail.info | lessJun 19 11:40:48 hermes postfix/qmgr[3975]: 40F2E5126FF4: removedJun 19 11:40:48 hermes postfix/virtual[4187]: 40F2E5126FF4: to=<[email protected]>, orig_to=<[email protected]>, relay=virtual, delay=0, delays=0/0/0/0, dsn=5.1.1, status=bounced (unknown user: "[email protected]")Jun 19 11:40:48 hermes postfix/qmgr[3975]: 3D7205126FDD: removedJun 19 11:40:48 hermes postfix/bounce[4188]: 3D7205126FDD: sender non-delivery notification: 40F2E5126FF4Jun 19 11:40:48 hermes postfix/qmgr[3975]: 40F2E5126FF4: from=<>, size=2590, nrcpt=1 (queue active)Jun 19 11:40:48 hermes postfix/cleanup[4184]: 40F2E5126FF4: message-id=<[email protected]>Jun 19 11:40:48 hermes postfix/virtual[4187]: 3D7205126FDD: to=<[email protected]>, relay=virtual, delay=0.02, delays=0.01/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "[email protected]")Jun 19 11:40:48 hermes postfix/qmgr[3975]: 3D7205126FDD: from=<[email protected]>, size=835, nrcpt=1 (queue active)Jun 19 11:40:48 hermes postfix/cleanup[4184]: 3D7205126FDD: message-id=<[email protected]>Jun 19 11:40:48 hermes postfix/pickup[3974]: 3D7205126FDD: uid=1001 from=<[email protected]>


    And ports:

    Code
    1. #netstat -lpnActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 127.0.0.1:12525 0.0.0.0:* LISTEN 562/policyd-weighttcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4014/apache2tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 3966/mastertcp 0 0 127.0.0.1:9876 0.0.0.0:* LISTEN 3860/imscp_daemontcp 0 0 198.23.228.223:53 0.0.0.0:* LISTEN 3995/namedtcp 0 0 127.0.0.2:53 0.0.0.0:* LISTEN 3995/namedtcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 3995/namedtcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 488/sshdtcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 3995/namedtcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3966/mastertcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 4014/apache2tcp 0 0 127.0.0.1:10023 0.0.0.0:* LISTEN 3867/postgrey.pid -tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN 3966/mastertcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 857/mysqldtcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 3966/mastertcp6 0 0 :::110 :::* LISTEN 2773/couriertcpdtcp6 0 0 :::143 :::* LISTEN 2779/couriertcpdtcp6 0 0 :::465 :::* LISTEN 3966/mastertcp6 0 0 :::21 :::* LISTEN 3977/proftpd: (accetcp6 0 0 :::22 :::* LISTEN 488/sshdtcp6 0 0 :::25 :::* LISTEN 3966/mastertcp6 0 0 :::993 :::* LISTEN 2803/couriertcpdtcp6 0 0 :::995 :::* LISTEN 2791/couriertcpdtcp6 0 0 :::587 :::* LISTEN 3966/masterudp 0 0 198.23.228.223:53 0.0.0.0:* 3995/namedudp 0 0 127.0.0.2:53 0.0.0.0:* 3995/namedudp 0 0 127.0.0.1:53 0.0.0.0:* 3995/named


    I have tried a manual telnet from the server and it works:

    Code
    1. #telnet alt4.gmail-smtp-in.l.google.com 25Trying 173.194.70.26...Connected to alt4.gmail-smtp-in.l.google.com.Escape character is '^]'.220 mx.google.com ESMTP y5si17268626eep.271 - gsmtphelo mydom.co.in250 mx.google.com at your servicemail from:<[email protected]>250 2.1.0 OK y5si17268626eep.271 - gsmtprcpt to:<[email protected]>250 2.1.5 OK y5si17268626eep.271 - gsmtpdata354 Go ahead y5si17268626eep.271 - gsmtpFrom: <[email protected]>Subject: This is a testTesting.250 2.0.0 OK 1371623122 y5si17268626eep.271 - gsmtp


    And if I install sendmail and try sending a mail with php, it works perfectly:

    Code
    1. Jun 19 12:12:00 hermes sendmail[6208]: r5J6fwkN006208: [email protected], [email protected] (1001/1001), delay=00:00:02, xdelay=00:00:01, mailer=relay, pri=30584, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r5J6fxGH006209 Message accepted for delivery)
    2. Jun 19 12:12:00 hermes sm-mta[6209]: r5J6fxGH006209: from=<[email protected]>, size=909, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=hermes.mydom.co.in.local [127.0.0.1]
    3. Jun 19 12:11:59 hermes sendmail[6208]: r5J6fwkN006208: [email protected], size=584, class=0, nrcpts=1, msgid=<[email protected]>, relay=vu2003@localhost
    4. Jun 19 12:11:58 hermes sendmail[6208]: r5J6fwkN006208: Authentication-Warning: hermes.mydom.co.in: vu2003 set sender to [email protected] using -f
    5. Jun 19 12:10:05 hermes sm-mta[6183]: starting daemon (8.14.3): SMTP+queueing@00:10:00
    6. Jun 19 12:10:05 hermes sm-mta[6181]: gethostbyaddr(127.0.0.2) failed: 1
    7. Jun 19 12:10:05 hermes sendmail[6138]: /etc/mail/aliases: 1 aliases, longest 4 bytes, 14 bytes total
    8. Jun 19 12:10:05 hermes sendmail[6138]: alias database /etc/mail/aliases rebuilt by root
    9. Jun 19 12:10:05 hermes sendmail[6138]: gethostbyaddr(127.0.0.2) failed: 1
    10. Jun 19 12:09:56 hermes postfix/master[4912]: terminating on signal 15

    Edited once, last by dzchimp ().

  • Update on this: [email protected] was my domain, and it seems that the issue was with delivering to it. On changing that to a gmail address, mail was delivered correctly.


    The issue seems related to this: http://ubuntuforums.org/showthread.php?t=1570792


    Edit1:
    Unsetting the following in /etc/postfix/main.cf causes mail to be delivered properly via php.


    Code
    1. virtual_mailbox_domains =


    Maybe my scenario is a bit different because my mail is managed by gmail although the domain to which the alias belongs is hosted on this server.

    Edited once, last by dzchimp ().



  • LOL LOL LOL


    No comment....

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Hello,


    I'm upping this because I've had the same problem on several servers and didn't take the time to find a proper solution so far.
    To sum up: on a clean server (Debian Squeeze), just after installing iMSCP (Version = 1.0.3.0), I create a domain mydomain.com with mail accounts enabled and I try to send a mail via php to [email protected], the mail "never leaves the server" even if I deactivate mail accounts after.


    It's exactly the same problem I had with iSPCP:
    http://isp-control.net/forum/printthread.php?tid=10133


    Is there a correct way to fix/configure this ?


    Thanks in advance !