Php – Postfix Not Sending Email to Some Addresses

emailPHPpostfix

I'm using Jetpack on WordPress, and it wasn't working. I was getting the following error:

Diagnostic-Code: X-Postfix; unknown user: "jake"

--60FD1138CAD.1354039466/example.com Content-Description: Undelivered Message

(example.com substituted for our domain)

We set up a test mail function, and that wasn't sending either. We changed the email to an outside email and it worked. Any thoughts why it won't send to an email that is at the same domain? Or why it sends to some emails but not others?

Upon running postconf -n, I get the following:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = example.com, Example, 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_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

Best Answer

When I send an email to jake@example.com, my client looks up your MX records, finds that you are using Google and then talks directly to Google's mail servers to send the email. My mail never ends up on your server.

When you send an email from your server to jake@example.com using PHP, PHP looks up its sendmail setting in php.ini and hands the mail off to that process to deliver. In your case, that is going to be Postfix. Since Postfix is capable of both accepting and sending emails (unlike a normal client or MUA), it first checks to see if it should accept this email itself or relay it on to some other server. It does this by comparing the domain after the @ symbol with the contents of the mydestinations config item. In your case, this is example.com and it matches so your Postfix decides to accept the mail itself instead of relaying it to Google. This is the root of where your problem lies.

After deciding to accept the mail itself, it then has to figure out where to put it. This can be a virtual user table or a real Unix user or an alias to delivers to a different user (virtual or real). In your server, none of these match. It looks like your user account is jakebuob, not jake and you don't have any virtual maps configured. So Postfix then bounces the message with a "User not found" message.

The easiest thing to change to fix this problem is to remove example.com from mydestination.

Related Topic