Ramblings from MostlyChris

Tech stuff and a bit more

Browsing Posts in Postfix

To create an autoresponder or vacation notice on a server using Postfix, I use procmail on an individual account basis. In order to do this, first create a .forward file in the user's home directory with the following (quotes are to be included).

"|IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #tina_fp"

Create a .procmailrc file in the same directory with the following:

SHELL=/bin/sh    # for other shells, this might need adjustment

:0 Whc: vacation.lock
 # Perform a quick check to see if the mail was addressed to us
* $^To:.*\<$\LOGNAME\>
 # Don’t reply to daemons and mailinglists
* !^FROM_DAEMON
 # Mail loops are evil
* !^X-Loop: racktest@fauxpanels.com
| formail -rD 8192 vacation.cache

  :0 ehc         # if the name was not in the cache
  | (formail -rI"Precedence: junk" \
       -A"X-Loop: racktest@fauxpanels.com" ; \
     echo "Hi,"; \
     echo "I will be out of the office from Monday August 2nd to Friday August 6th. "; \
     echo "If you need assistance, please send an email to info@blah.com or call 1-800-555-1212."; \
     echo "-Tina"; \
    ) | $SENDMAIL -oi -t

.

Replace the echo statements with your own reply text.

There is a method to bypass RBL checking for certain addresses and domains in Postfix. This assumes that you are using RBL checking in the first place.

First, create an rbl_override file in /etc/postfix.

vi /etc/postfix/rbl_override

Place the domains and/or IP addresses you would like whitelisted into that file.

192.168.0.1
192.168.0.2
domain.com
subdomain.example.com

Create the hash of that file.

postmap /etc/postfix/rbl_override

Edit the main.cf file.

vi /etc/postfix/main.cf

Locate the section marked smpt_recipient_restrictions. You need to add the following to that.

check_client_access hash:/etc/postfix/rbl_override

Restart Postfix and you should be all set.

/etc/init.d/postfix restart

Change to the Postfix configuration directory. Usually this is in /etc/postfix.

cd /etc/postfix

Open the sender_access file or create it if it doesn't exist.

vi sender_access

Add the email address you want rejected on a new line in the file followed by REJECT.

email@address.com REJECT

Save the file.

Create the server_access database with the postmap command

postmap hash:sender_access

Edit the main.cf file and add the following

smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access

Restart Postfix

service postfix restart

Check your logs to make sure everything is good.

Postfix has some spam fighting abilities built in. However, you will need to enable them for them to work. Just throw the code below into your main.cf file and restart Postfix. Voila.

smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_pipelining,
reject_non_fqdn_recipient,
reject_non_fqdn_sender,
reject_unknown_recipient_domain,
reject_unauth_destination,
reject_invalid_hostname,
reject_rbl_client sbl.spamhaus.org,
reject_rbl_client xbl.spamhaus.org,
permit