nema5pic
vi-hell
clippie

Postfix


~~

Commands/Troubleshooting

config files in /etc/postfix
	main.cf
logs in /var/log/maillog

postfix reload		# after doing changes to config files
postfix flush 		# churn thru the mail backlog ==? postqueue -f
mailq			# check the mailq  == postqueue -p
postsuper -d 6DF3D6A444 # remove a specific mail in the queue with the specified id
postsuper -d deferred   # remove all deferred mail (but not other errors).   CAREFUL!
postsuper -d ALL        # remove all queue mail (all those shown by mailq).  VERY CAREFUL!


postconf -d    # show default param for postfix 
postconf -d  | grep mydomain
postconf -d  | grep myhost 

postconf -n             # to find out what settings are overruled by your main.cf. , 
                        # show what postfix parsed/took out of config file
postconf mail_version   # To find out what Postfix version you have, execute the command 

address rewritting bible :)

http://www.postfix.org/ADDRESS_REWRITING_README.html#masquerade

mascarade is to hide some early portion of the domain name, 
eg strip na.nova.com to nova.com


/etc/postfix/canonical
	# change domain address in both sender and recipient
	# main for username to first.last, 
	# but should be able to specify domain as in eg of sender-canonical
	# postmap ./canonical
	# postmap -q "string" ./canonical # ??
	# eg:
	@local          @lbl.gov
	@beagle         @lbl.gov
	@beagle.local   @lbl.gov




/etc/postfix/sender-canonical		# sender only, need to enable clause in main.cf.  
	# eg content:
	@local          @lbl.gov
	@beagle         @lbl.gov
	@beagle.local   @lbl.gov
	# eg content 2:
	@local		@na.grumpy.com
	@headnode	@na.grumpy.com
	@headnode.local	@na.grumpy.com


/etc/postfix/recipient-canonical	# eg:
	root@na.grumpy.com	root
	@mycluster.local	@na.grumpy.com
	eg2: 
	root@beagle.lbl.gov    root
	@gretadev              @lbl.gov
	@beagle                @lbl.gov
	@beagle.local          @lbl.gov



after update to the file, recreate hash (or dbm) as:
sudo postmap /etc/postfix/sender-canonical

Specify dbm instead of hash if your system uses dbm files instead of db files. 
To find out what lookup tables Postfix supports, use the command 
"postconf -m".
But more importantly, see whether main.cf refer to hash:/etc/postfix/filename or dbm

Execute the command "postmap /etc/postfix/relay_recipient" 
whenever you change the relay_recipients table.
	eg of relay-canonical (tailing x means "checked" to allow domain to relay):
	@lbl.gov         x

	# added additional domain on 2020.0718, 
        # but not likely needed, as all email, even those to gmail.com, were forwarded to onward smtp server
	@berkeley.edu    x
	@es.net          x
	@nersc.gov       x



Execute the command "postmap /etc/postfix/transport" whenever you change the transport table.


main.cf

Example for cluster head node (which act as relay host for all compute nodes):

mydestination = $mydomain, $myhostname, localhost.$mydomain
mynetworks = 10.10.8.0/24, 127.0.0.0/8, 192.168.2.0/24
inet_interfaces = all
append_dot_mydomain = no
sender_canonical_maps = hash:/etc/postfix/sender-canonical
recipient_canonical_maps = hash:/etc/postfix/recipient-canonical
##
relayhost = smtp.na.skinforum.org
mydomain = na.skinforum.org
myorigin = headnode.na.skinforum.org

Example for node sending mail to be relayed. SASL auth is turned off, ok only for private network with no possible outside access.
mydestination = $mydomain, $myhostname, localhost.$mydomain   
relayhost = 10.2.3.4:25
mydomain = gretadev 
mynetworks = 127.0.0.0/8 
smtp_sasl_auth_enable = no
smtp_use_tls = no                # DOE special anyway :p

Ref

interesting command and script to delete deferred mail. http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html









Copyright info about this work

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike2.5 License. Pocket Sys Admin Survival Guide: for content that I wrote, (CC) some rights reserved. 2005,2012 Tin Ho [ tin6150 (at) gmail.com ]
Some contents are "cached" here for easy reference. Sources include man pages, vendor documents, online references, discussion groups, etc. Copyright of those are obviously those of the vendor and original authors. I am merely caching them here for quick reference and avoid broken URL problems.



Where is PSG hosted these days?