Postfix / Spamassassin: Fixed mail returned to sender

I am having an issue with a newly configured mail server where spam messages that are spoofed from the local domain are actually received by the mail server, the mail is not delivered as is, spamassassin sends it as spam and then emails "Undelivered Mail Returned to Sender "for a forged local user.

I know there is a way to fix this in the config, but I have no idea where I hope someone can point me in the right direction.

To be clear, the mail server is not relaying, this is just a local user issue. I want postfix to reject any mail, presumably from local users, that are not sent internally. This will stop this problem.

Here's an email to show what's going on. I changed the domain to example.com.au.

###############################################


This is the mail system at example.com.au.

Sorry to inform you that your message cannot be delivered to one or more recipients. It is attached below.

For further assistance, please send an email to the postmaster.

If you do, please include this issue report. You can remove your own text from the attached returned message.

Mail system

: host 127.0.0.1 [127.0.0.1] said: 554 5.7.0 Reject, id = 11887-07 - SPAM (in response to the end of the DATA command)
?
Reporting-MTA: DNS; example.com.au
X-Postfix-Queue-ID: 661DC5D1DE
X-Postfix-Sender: rfc822; dan@example.com.au Arrival date: Tue May 5, 2009 06:21:38 AM +1000 (EST)


Ultimate recipient: rfc822; dan@example.com.au Original-Recipient: rfc822; dan@example.com.au Action: Failed Status: 5.7.0 Remote-MTA: dns; 127.0.0.1 Diagnostic code: smtp; 554 5.7.0 Reject, id = 11887-07 - SPAM? From: Berenice Penez Date: Mon, May 4 , 2009 10:21:41 PM +0200 To: Topic: Is this you on the forum? Reliable quality and no delays with shipping! Super Online Store for Disease Treatment http://www.xopfekec.cn/














###############################################

Postfix main.cf (important parts, incomplete)

readme_directory = / usr / share / doc / postfix
mydomain_fallback = localhost
message_size_limit = 0
mailbox_size_limit = 0
myhostname = example.com.au
mailbox_transport = cyrus
mydomain = example.com.au
inet_interfaces = all
enable_server_options = yes
mydestination =. $ myhost the mydomain $, localhost, example.com.au
smtpd_sasl_auth_enable = yes or The smtpd_use_pw_server = yes or The smtpd_recipient_restrictions = allow_sasl_authenticated, allow_mynetworks, reject_unauth_destination, reject_unknown_recipient_domain, reject_unknown_sender_domain, reject_invalid_hostname
smtpd_pw_server_security_options = plain, the login
content_filter = the smtp-amavis: [127.0.0.1]: 10024
mynetworks = 127.0.0.0/8, 10.0.1.0/24
smtpd_client_restrictions = allow_sasl_authenticated, reject_rbl_client dnsbl.sorbs.net

-2


source to share


1 answer


Several different points:

  • It should be on serverfault.com, but since I'm not in beta, I'll answer it here.

  • The result of postconf -n is better than including what you think are relevant lines in main.cf. Also include the relevant lines from master.cf if you have parameter overrides or other settings in there.

  • Do not then accept scanned mail. If you are using SpamAssassin as a post-queue filter in Postfix (the usual way to run it), you need to either flag and deliver (and filter using client-side rules) or quarantine mail without notifying the sender. In terms of your question, you are probably the backscatter source. Stop that. See http://www.postfix.org/BACKSCATTER_README.html for example . Consider amavisd-new to integrate SpamAssassin into Postfix with all the useful features.

  • Consider rolling all your restrictions in smtpd_recipient_restrictions. It is generally easier to manage a linear flow of restrictions than it is to interact with smtpd_ {client, helo, sender, recipient} _restrictions.

  • To prevent Postfix from being sent from outside, add a sender_access map that rejects the send mail request from your domains:

smtpd_recipient_restrictions = 
  permit_sasl_authenticated, 
  permit_mynetworks, 
  reject_unauth_destination, 
  check_sender_access hash: $ config_directory / reject_mydomains
  reject_unknown_recipient_domain,
  reject_unknown_sender_domain,
  reject_invalid_hostname

And in reject_mydomains

example.com.au REJECT you are not me

This will likely be susceptible to false positives with mail that comes from senders with a legitimate (?) Reason for using your domain as an envelope sender (e-cards, invitations, maybe some outsourced services like polls or whatnot). You can whitelist your "you-not-me" rules with the client_access map in front of your sender_access map that returns OK or the appropriate restriction class (see http://www.postfix.org/RESTRICTION_CLASS_README.html ).

You can use similar HELO checks to prune HELO-ing clients with custom hostname / IP or known bad HELO strings



smtpd_recipient_restrictions = 
  permit_sasl_authenticated, 
  permit_mynetworks, 
  reject_unauth_destination, 
  check_helo_access hash: $ config_directory / helo_checks
  check_sender_access hash: $ config_directory / reject_mydomains
  reject_unknown_recipient_domain,
  reject_unknown_sender_domain,
  reject_invalid_hostname

and in helo_checks:

example.com.au REJECT BAD-HELO you are not example.com.au
mailserver.example.com.au REJECT BAD-HELO you are not me
localhost REJECT BAD-HELO you are not me
localhost.localdomain REJECT BAD-HELO you are not me
# where 1.2.3.4 is the IP of your server
1.2.3.4 REJECT BAD-HELO you are not me
127.0.0.1 REJECT BAD-HELO you are not me

Finally, it is a very good idea to sign up for a reputable service like RBL. The best RBL for most purposes is zen.spamhaus.org . It can be used for light to moderate workloads, and if your usage is large enough to pass their free / paid threshold, the cost is well worth it. To configure in Postfix add

reject_rbl_client zen.spamhaus.org

to your smtpd_recipient_restrictions. Do this after your cheap local checks to save load and latency DNS requests, but before costly local checks like reject_unverified_recipient (you don't use this and probably don't need it from the problem description).

+2


source







All Articles