1

I am moving a site to another server and am having an issue with PHP mail. But only when sending mail to the host domain e.g [email protected].

mail($send_to, 'Web contact' ,$message,null,"-r [email protected]");

The only way I can get mail to send is by adding the -r flag it doesn't seem to matter what e-mail address is entered after the flag.

This is a migration from Centos 5 to 6 and I believe mail is now using Postfix as opposed to sendMail.

Is there a Postfix setting that I can change to stop having to add this flag to every call of the mail function?

Additionally is there a way to force the use of sendMail instead of using Postfix if I can't fix this?

I should have mentioned I know that the mail is been routed internally as is shown from the log:

EDIT

This is failed attempt without flag

May 14 16:13:12 test sendmail[10244]: t4EFDCLq010244: from=apache, size=169, class=0, nrcpts=1, msgid=<[email protected]>, relay=apache@localhost
May 14 16:13:12 test postfix/smtpd[10245]: connect from localhost[127.0.0.1]
May 14 16:13:12 test postfix/smtpd[10245]: 9EFB3256738: client=localhost[127.0.0.1]
May 14 16:13:12 test postfix/cleanup[10248]: 9EFB3256738: message-id=<[email protected]>
May 14 16:13:12 test sendmail[10244]: t4EFDCLq010244: [email protected], ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30169, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 9EFB3256738)
May 14 16:13:12 test postfix/qmgr[10102]: 9EFB3256738: from=<[email protected]>, size=592, nrcpt=1 (queue active)
May 14 16:13:12 test postfix/smtpd[10245]: disconnect from localhost[127.0.0.1]
May 14 16:13:12 test postfix/smtp[10249]: 9EFB3256738: to=<[email protected]>, relay=mail.example.com[748.31.105.444]:25, delay=0.1, delays=0.04/0.01/0.01/0.03, dsn=5.0.0, status=bounced (host mail.example.com[748.31.105.444] said: 550-Verification failed for <[email protected]> 550-No Such User Here" 550 Sender verify failed (in reply to RCPT TO command))
May 14 16:13:12 test postfix/cleanup[10248]: B47B625675D: message-id=<[email protected]>
May 14 16:13:12 test postfix/bounce[10250]: 9EFB3256738: sender non-delivery notification: B47B625675D
May 14 16:13:12 test postfix/qmgr[10102]: B47B625675D: from=<>, size=2524, nrcpt=1 (queue active)
May 14 16:13:12 test postfix/qmgr[10102]: 9EFB3256738: removed
May 14 16:13:12 test postfix/smtp[10249]: B47B625675D: to=<[email protected]>, relay=mail.example.com[748.31.105.444]:25, delay=0.03, delays=0/0/0.01/0.02, dsn=5.0.0, status=bounced (host mail.example.com[748.31.105.444] said: 550 No Such User Here" (in reply to RCPT TO command))
May 14 16:13:12 test postfix/qmgr[10102]: B47B625675D: removed

And this is with the flag

May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: Authentication-Warning: example.com: apache set sender to [email protected] using -r
May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: [email protected], size=169, class=0, nrcpts=1, msgid=<[email protected]>, relay=apache@localhost
May 14 16:13:23 test postfix/smtpd[10245]: connect from localhost[127.0.0.1]
May 14 16:13:23 test postfix/smtpd[10245]: 3B3EF256738: client=localhost[127.0.0.1]
May 14 16:13:23 test postfix/cleanup[10248]: 3B3EF256738: message-id=<[email protected]>
May 14 16:13:23 test postfix/qmgr[10102]: 3B3EF256738: from=<[email protected]>, size=662, nrcpt=1 (queue active)
May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: [email protected], [email protected] (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30169, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 3B3EF256738)
May 14 16:13:23 test postfix/smtpd[10245]: disconnect from localhost[127.0.0.1]
May 14 16:13:24 test postfix/smtp[10249]: 3B3EF256738: to=<[email protected]>, relay=mail.example.com[748.31.105.444]:25, delay=1.4, delays=0.03/0/0.01/1.3, dsn=2.0.0, status=sent (250 OK id=1Ysup9-0001Rr-Jv)
May 14 16:13:24 test postfix/qmgr[10102]: 3B3EF256738: removed

The issues appears to be the user apache is getting bounced by Postfix, ideally I would like Postfix to send anyway for this user.

Postfix config

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = localhost.$mydomain
mydomain = example.com
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
12
  • Added log, as mentioned it is being routed internally to the "root" mail box
    – Kline
    May 14, 2015 at 10:38
  • 4
    Your log shows a successful delivery. What exactly is the problem? May 14, 2015 at 10:38
  • Please list detailed which mails are delivered to which host and what you want. You neither state the current and expected behavior of your server nor do you provide concrete configurations, or a description of your setup (i.e. correct host and domain names).
    – sebix
    May 14, 2015 at 10:43
  • As I have mentioned the problem only occurs when sending mail to the domain of the host, i.e those mails are routed internally to the "root" users mail folder. All other e-mails to other domains are sent correctly i.e externally.
    – Kline
    May 14, 2015 at 11:00
  • What is the system's hostname? May 14, 2015 at 11:17

2 Answers 2

2

First you need to remove one of MTA. Having two MTAs in one system can yield unexpected result. Because I only have experience with postfix, then I suggest you to remove sendmail. With this removal, mail command will use postfix instead sendmail as default agent.

yum remove sendmail

Second, you can set default sendmail parameter in php.ini with sendmail_path parameter for example

sendmail_path = '/usr/sbin/sendmail -t -i -f [email protected]'

PS: according to this man page, -r flag is obsolete form of the -f flag. So, I prefer to use -f.

Third regarding your comment:

From the log I can see it is bouncing because [email protected] does not exist. I have added that and this solves the problem but is there a setting in Postfix I can add so that [email protected] doesn't need to be created?

This error message

550-Verification failed for 550-No Such User Here" 550 Sender verify failed

wasn't thrown by postfix. The email has been rejected by your actual mail server mail.**z*.net which running Exim. You need to talk to the Exim administrator why it behaves like that

1

In your main.cf is a parameter called mydestination. Remove the domain name form there, so mails to the domain won't be delivered locally no longer.

Before:

mydestination = $myhostname, $mydomain

After:

mydestination = $myhostname

$myhostname should remain in this list for the internal mails (cron, apt, error messages, etc.)

4
  • I still don't understand the connection between mydestination and flag -r in mail command. Anyway, based on his mail.log, I believe that his problem can be solved by this answer
    – masegaloeh
    May 14, 2015 at 11:55
  • -r sets the from address, see the manpage of mail.
    – sebix
    May 14, 2015 at 13:22
  • 1
    Yes, that's my point. Flag -r only affected the sender address, but based the mail.log (and your solution) the problem is mydestination. AFAIK there are no correlation between sender address and mydestination parameter.
    – masegaloeh
    May 14, 2015 at 13:34
  • I have just tried that and quite a lot of other combinations for mydestination but it is not fixing the problem.
    – Kline
    May 14, 2015 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .