-4

So I have setup an Ubuntu server and want to use postfix in order to sendmail via php.

The server host: example.com

When the server sends an email to anything@example.com, I get an error. If sending to any other address (someone@anotherdomain.com), it works fine.

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = localhost
inet_protocols = all
mailbox_size_limit = 0
mydestination = example.com, localhost.localdomain, , localhost
myhostname = example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated 
defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

When I send mail via php to example.com addresses I get the following error:

exception 'Zend\Mail\Protocol\Exception\RuntimeException' with message '5.1.1 <support@example.com>: Recipient address rejected: User unknown in local recipient table

When I send mail via php to AnyOtherDomain.com there is NO ERROR:

The actual mail for example.com is handled by a third party server. All SPF / DKIM records are in place so sending works fine so long as it is to third party domains.

Obviously this is a setting, which one I am still working to figure out.

EDIT:

Digging into the mail logs I note this:

Apr  6 13:37:57 somename postfix/local[25416]: 3625CE2EB7: to=<support@example.com>, relay=local, delay=0.03, delays=0.02/0.01/0/0.01, dsn=5.1.1, status=undeliverable (unknown user: "support")
Apr  6 13:42:29 xxxxx postfix/smtpd[25501]: connect from localhost[127.0.0.1]
Apr  6 13:42:29 xxxxx postfix/smtpd[25501]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <support@example.com>: Recipient address rejected: User unknown in local recipient table; from=<no-reply@example.com> to=<support@example.com> proto=ESMTP helo=<localhost>
Apr  6 13:42:29 xxxxx postfix/smtpd[25501]: disconnect from localhost[127.0.0.1]

So I believe the server is trying to send to a user rather than an email address...

  • Could you fix the output of postconf -n? Also, seems that you are using Zendmail for something. Could you elaborate? The message basically means that you are using a local table or local_recipient_maps – Braiam Apr 6 '16 at 13:14
  • Updated formatting - the zend stuff uses SendMail(). If the email used is: support@example.com it dies, if customer@gmail.com is used, it works fine. – HappyCoder Apr 6 '16 at 13:21
  • Does the user getting the mail exist? The solution might be as simple as adding support: root to /etc/aliases. – tarleb Apr 6 '16 at 13:42
  • The user does not exist. Not a solution to add a user for each mail address. – HappyCoder Apr 6 '16 at 13:53
2

The reason this was not working was because I had set:

MyDomains to include example.com

From the manual

The mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine. The default is to receive mail for the machine itself.

This line was the culprit:

mydestination = example.com, localhost.localdomain, , localhost

Updated it to:

localhost.localdomain, localhost

Basically, PostFix was attempting to handle all mail at Example.com instead of sending it off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.