I'm going crazy troubleshooting a weird issue.
I'm running a LAMP installation using CentOS. My domain has a MX record pointing to another mail server which i rent from my ISP.
All mails sent via sendmail from my domain to external accounts works fine. Receiving mails on
email@mydomain.com from external accounts works fine.
Sending email to
email@mydomain.com from mydomain.com does ONLY work for root user not for apache user.
Here is how i've tested:
ROOT User
command '/usr/sbin/sendmail -v
email@mydomain.com < message.txt'
produces
Code:
email@mydomain.com... Connecting to [127.0.0.1] via relay...
220 mydomain.com ESMTP Sendmail 8.13.1/8.13.1; Mon, 12 Sep 2011 15:51:18 +0200
>>> EHLO localhost.localdomain
250-mydomain.com Hello ipXXX-XXX-132-248 [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<root@localhost.localdomain> SIZE=607 AUTH=root@localhost.localdomain
250 2.1.0 <root@localhost.localdomain>... Sender ok
>>> RCPT To:<email@mydomain.com>
>>> DATA
250 2.1.5 <email@mydomain.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 p8CDpI2h023664 Message accepted for delivery
email@mydomain.com... Sent (p8CDpI2h023664 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 mydomain.com closing connection
/var/log/maillog
Code:
Sep 12 15:58:36 ipXXX-XXX-132-248 sendmail[23786]: p8CDwamh023786: from=root, size=607, class=0, nrcpts=1, msgid=<201109121358.p8CDwamh023786@localhost.localdomain>, relay=root@localhost
Sep 12 15:58:36 ipXXX-XXX-132-248 sendmail[23787]: p8CDwaUb023787: from=<root@localhost.localdomain>, size=913, class=0, nrcpts=1, msgid=<201109121358.p8CDwamh023786@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=ipXXX-XXX-132-248 [127.0.0.1]
Sep 12 15:58:36 ipXXX-XXX-132-248 sendmail[23786]: p8CDwamh023786: to=email@mydomain.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30607, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p8CDwaUb023787 Message accepted for delivery)
Sep 12 15:58:36 ipXXX-XXX-132-248 sendmail[23789]: p8CDwaUb023787: to=<email@mydomain.com>, delay=00:00:00, xdelay=00:00:00, mailer=smtp, pri=120913, relay=smtp.myisp.com. [217.116.215.3], dsn=2.0.0, stat=Sent (Ok: queued as ED95BB8B6D)
APACHE User
command '/usr/sbin/sendmail -v
email@mydomain.com < message.txt'
produces
Code:
email@mydomain.com... Connecting to [127.0.0.1] via relay...
220 mydomain.com ESMTP Sendmail 8.13.1/8.13.1; Mon, 12 Sep 2011 15:53:17 +0200
>>> EHLO localhost.localdomain
250-mydomain.com Hello ipXXX-XXX-132-248 [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<apache@localhost.localdomain> SIZE=607 AUTH=apache@localhost.localdomain
250 2.1.0 <apache@localhost.localdomain>... Sender ok
>>> RCPT To:<email@mydomain.com>
>>> DATA
250 2.1.5 <email@mydomain.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 p8CDrH46023701 Message accepted for delivery
email@mydomain.com... Sent (p8CDrH46023701 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 mydomain.com closing connection
/var/log/maillog
Code:
Sep 12 15:56:23 ipXXX-XXX-132-248 sendmail[23741]: p8CDuNas023741: from=apache, size=607, class=0, nrcpts=1, msgid=<201109121356.p8CDuNas023741@localhost.localdomain>, relay=apache@localhost
Sep 12 15:56:23 ipXXX-XXX-132-248 sendmail[23742]: p8CDuNoA023742: from=<apache@localhost.localdomain>, size=919, class=0, nrcpts=1, msgid=<201109121356.p8CDuNas023741@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=ipXXX-XXX-132-248 [127.0.0.1]
Sep 12 15:56:23 ipXXX-XXX-132-248 sendmail[23741]: p8CDuNas023741: to=email@mydomain.com, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30607, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p8CDuNoA023742 Message accepted for delivery)
Sep 12 15:56:23 ipXXX-XXX-132-248 sendmail[23744]: p8CDuNoA023742: to=<email@mydomain.com>, delay=00:00:00, xdelay=00:00:00, mailer=smtp, pri=120919, relay=smtp.myisp.com. [217.116.215.3], dsn=2.0.0, stat=Sent (Ok: queued as 0EB03B81FE)
No errors in /var/log/messages and in both cases the message is queued and accepted for delivery according to the maillog.
The email sent when run by root is present in my inbox, the one sent from apache is not. If i send from apache user to an external account (say hotmail.com) it works fine.
Any ideas ?
Thanks in advance.