Postfix exercise ---------------- Exercise notes: To run this exercise, we recomment that you open one window (or screen) where you are logged in as root, and one where you are logged in as "sanog": ALT-: login: sanog password: $ ALT- login: root passwod: # ... then you can switch back and forth during the exercises. Remember: '#' indicates that you should be doing this as root '$' indicates that you should be doing this as a non-root user (sanog) 1. Make sure that postfix is running: # ps ax | grep postfix You should see the "master" process for postfix running 2. Let's create a new configuration for postfix # cd /usr/local/etc/postfix # postconf -n > main.cf.new # mv main.cf.new main.cf 3. Restart postfix, and check that mail is working: # postfix stop # postfix start # echo "testing mail" | mail -s "test" sanog@localhost # tail /var/log/maillog You should see something like this: Jul 17 17:10:56 noc postfix/pickup[67305]: CCF367303F: uid=0 from= Jul 17 17:10:56 noc postfix/cleanup[67454]: CCF367303F: message-id=<20100717111056.CCF367303F@noc.ws3.conference.sanog.org> Jul 17 17:10:56 noc postfix/qmgr[59834]: CCF367303F: from=, size=356, nrcpt=1 (queue active) Jul 17 17:10:56 noc postfix/local[67456]: CCF367303F: to=, orig_to=, relay=local, delay=0.16, delays=0.1/0/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox) Jul 17 17:10:56 noc postfix/qmgr[59834]: CCF367303F: removed 4. Try and read the mail Note: do this as the "sanog" user! $ id uid=1001(sanog) gid=1001(sanog) groups=1001(sanog) $ mutt Mutt will ask you: /home/sanog/Mail does not exist. Create it? ([yes]/no): ... answer 'yes' You are now using "mutt", a simple mail client. You can use the arrows to move up and down, and press on a mail you want to read. You should be able to see the mail you sent to the sanog user. To quit: press 'q', and 'q' again to leave the program. Note: If you are lost, you can always press the '?' key to get help on using mutt. 5. Let's modify the /etc/aliases file, so we can receive mail for other system users into our mailbox: (As root!) # ee /etc/aliases (or vi /etc/aliases) Find the line: # root: me@my.domain And replace it with: root: sanog ... Look at the rest of the file, and look at the various system aliases. Save the file, and run the "newaliases" command: # newaliases # 6. Try sending mails to the "postmaster" user # echo "test to postmaster" | mail -s "test postmaster" postmaster@localhost Send another mail but this time, to operator@wsXX.ws3.conference.sanog.org ... replace "XX" with the number of your own PC, for example: # echo "test to my own machine" | mail -s "test operator" operator@wsXX.ws3.conference.sanog.org 7. Check that you received these mails $ mutt Check that all mails have been received A useful key is the 'h' key -- while displaying a mail, this will toggle between showing "full" headers, and limited headers. Use this feature to inspect the mails in your mailbox. Note the "To:" and "X-Original-To:" headers. 8. Send mail to other users in the class! Since you were able to send mail to your OWN machine, then you can also send mails to other users in the class: $ echo "hello from wsXX" | mail -s "mail from wsXX" sanog@wsYY.ws3.conference.sanog.org $ echo "hello from wsXX" | mail -s "mail from wsXX" sanog@wsZZ.ws3.conference.sanog.org ... where "XX" is yourself, YY and ZZ are other PCs in the room