0

I have set up my Posfix email SMTP server on Ubuntu 16 and it's working. I used to use the SMTP server of my hosting company but I rather use my own.

I'm sending email with Java Mail but the difference is that when I send trough hosting company and the recipient address is wrong I get:

com.sun.mail.smtp.SMTPAddressFailedException: 450 4.1.2 : Recipient address rejected: Domain not found

But when I send with Postfix no Exception is thrown. I check the Postfix log and the message is:

Action: failed Status: 5.4.4 Diagnostic-Code: X-Postfix; Host or domain name not found. Name service error for name=somebod@ggmail.com type=AAAA: Host not found

But this is never propagated as java exception.

Anybody has a clue how to set up Postfix to behave the same way?

Thanks, Hugo

0

Put reject_unknown_recipient_domain in smtpd_recipient_restrictions before permit_mynetworks, permit_sasl_authenticated, and/or permit_tls_clientcerts.

If reject_unknown_sender_domain is missing from the config, or if permit_* appears before reject_unknown_sender_domain then postfix will allow all client senders matching the permit rule to send email without the recipient domain being checked. Postfix will accept the incoming mail, queue it, and only notice the domain doesn't exist when it attempts to deliver it....and then bounce the message.

If reject_unknown_sender_domain appears first, then it is checked for all clients, whether they match a permit_* rule or not, and the email is rejected with a 5xx code.

In postfix, the order of rules is always significant.

Example:

If you have the following in main.cf:

smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/junk,
  check_client_access hash:/etc/postfix/junk,
  check_helo_access hash:/etc/postfix/junk,
  reject_unauth_pipelining,
  permit_tls_clientcerts,
  permit_sasl_authenticated,
  permit_mynetworks

add reject_unknown_recipient_domain somewhere before the permit lines, e.g.:

smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/junk,
  check_client_access hash:/etc/postfix/junk,
  check_helo_access hash:/etc/postfix/junk,
  reject_unauth_pipelining,
  reject_unknown_recipient_domain,
  permit_tls_clientcerts,
  permit_sasl_authenticated,
  permit_mynetworks

If you don't already have a smtpd_recipient_restrictions rule, add one like:

smtpd_recipient_restrictions = reject_unauth_pipelining,
  reject_unknown_recipient_domain,
  permit_mynetworks

You should, however, do some more research on configuring postfix.

  • Hi, Do I add this line in main.cf? smtpd_recipient_restrictions = reject_unknown_recipient_domain before line smtpd_relay_restrictions = permit_mynetworks .... – Hugo Larson Jan 11 '18 at 6:51
  • yes. there will probably be an existing smtpd_recipient_restrictions=... rule in main.cf - edit that if there is. otherwise add one. – cas Jan 11 '18 at 6:52
  • I actually only want to use postfix for sending email from localhost – Hugo Larson Jan 11 '18 at 7:06
  • Hi. A followup question. Is it possible to configure postfix to have a Exception thrown also when mail is bounced? Tanks. – Hugo Larson Dec 11 '18 at 8:05

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.