HomeBanner

Servers: Postfix

Postfix

1. How can I configure postfix so my correct email address goes out ?
2. How do I use procmail with Postfix ?
3. How can I stop receiving "*.bat" "*.exe" attachments while using Postfix ?
4. How can I update the proxy_interface parameter when my real ip changes
1.

How can I configure postfix so my correct email address goes out ?

Applies to 8.0

Keith Winston

What you need is the postfix sender_canonical lookup table. It will translate all outgoing addresses in the table to how you define them. This all has to be done as root

  1. Edit /etc/postfix/sender_canonical and add this line to it:

    login_name@localhost.domain    desired_username@desired_outgoing_domain
    	

    Note

    Change the above to reflect your case

  2. Then, create the hash file (sender_canonical.db) with:

    postmap sender_canonical
    	
  3. Then, make sure you have told postfix to use it. Edit /etc/postfix/main.cf and make sure it has this line (it may be toward the end of the file). If it's not in there, add it:

    sender_canonical_maps = hash:/etc/postfix/sender_canonical
    	
  4. Finally, reload:

    postfix reload
    	

By the way, most mail servers will let you send to them directly as long as you have valid sender address. However, some mail servers only accept mail from machines that have DNS MX records. I send out mail directly and I've only had 1 refuse to accept my mail in the last 3 months.

2.

How do I use procmail with Postfix ?

in /etc/postfix/main.cf Search for

#mailbox_command = /some/where/procmail
      

And change it to your path to procmail, which is /usr/bin/procmail unless you changes the procmail installation.

3.

How can I stop receiving "*.bat" "*.exe" attachments while using Postfix ?

in /etc/postfix/main.cf enable the body checks with this line:

body_checks = pcre:/etc/postfix/body_checks
      

Now put something in this file (/etc/postfix/body_checks):

/^(.*)name\=\"(.*)\.(hta|vb[esx]|ws[fh]|js[e]|bat|cmd)\"$/ REJECT
      

This will filter attachments (probably dangerous) of various types. Remove from the above line, whatever you want to allow.

Of course you can add some more lines to make postfix a simple spam filter:

/special offer email/       REJECT
/mortgage rates/            REJECT
      

4.

How can I update the proxy_interface parameter when my real ip changes

Theo v Werkhoven

Use a service like whatismyip.com e.g.:

publicipv4=` lynx --dump http://www.whatismyip.com/ | \
egrep --only-matching -e "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -1'

Note

(shameless copy from a 6to4 setup script, GPL Copyleft 2003 Sander, surfipv6 at xs4all .nl)

As many time as you need to, poll whatismyip.com in a cronjob, and use 'postconf -e "proxy_interface=$publicipv4"; postfix reload' to re-set the IP. Save the IP, and only change proxy_interface when you get another IP of course.

This only works when your ISP has no mandatory proxy server.


Updated: Wed, 03 Mar 2004
Valid CSS!Valid HTML 4.01!