1 | Postfix exercise |
---|
2 | ---------------- |
---|
3 | |
---|
4 | Exercise notes: |
---|
5 | |
---|
6 | To run this exercise, we recomment that you open |
---|
7 | one window (or screen) where you are logged in as root, and |
---|
8 | one where you are logged in as "sanog": |
---|
9 | |
---|
10 | ALT-<F1>: |
---|
11 | |
---|
12 | login: sanog |
---|
13 | password: |
---|
14 | |
---|
15 | $ |
---|
16 | |
---|
17 | ALT-<F2> |
---|
18 | |
---|
19 | login: root |
---|
20 | passwod: |
---|
21 | |
---|
22 | # |
---|
23 | |
---|
24 | ... then you can switch back and forth during the exercises. |
---|
25 | |
---|
26 | Remember: '#' indicates that you should be doing this as root |
---|
27 | '$' indicates that you should be doing this as a non-root user (sanog) |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | 1. Make sure that postfix is running: |
---|
32 | |
---|
33 | # ps ax | grep postfix |
---|
34 | |
---|
35 | You should see the "master" process for postfix running |
---|
36 | |
---|
37 | 2. Let's create a new configuration for postfix |
---|
38 | |
---|
39 | # cd /usr/local/etc/postfix |
---|
40 | |
---|
41 | # postconf -n > main.cf.new |
---|
42 | # mv main.cf.new main.cf |
---|
43 | |
---|
44 | 3. Restart postfix, and check that mail is working: |
---|
45 | |
---|
46 | # postfix stop |
---|
47 | # postfix start |
---|
48 | |
---|
49 | # echo "testing mail" | mail -s "test" sanog@localhost |
---|
50 | |
---|
51 | # tail /var/log/maillog |
---|
52 | |
---|
53 | You should see something like this: |
---|
54 | |
---|
55 | Jul 17 17:10:56 noc postfix/pickup[67305]: CCF367303F: uid=0 from=<root> |
---|
56 | Jul 17 17:10:56 noc postfix/cleanup[67454]: CCF367303F: message-id=<20100717111056.CCF367303F@noc.ws3.conference.sanog.org> |
---|
57 | Jul 17 17:10:56 noc postfix/qmgr[59834]: CCF367303F: from=<root@noc.ws3.conference.sanog.org>, size=356, nrcpt=1 (queue active) |
---|
58 | Jul 17 17:10:56 noc postfix/local[67456]: CCF367303F: to=<sanog@localhost.ws3.conference.sanog.org>, orig_to=<sanog@localhost>, relay=local, delay=0.16, delays=0.1/0/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox) |
---|
59 | Jul 17 17:10:56 noc postfix/qmgr[59834]: CCF367303F: removed |
---|
60 | |
---|
61 | 4. Try and read the mail |
---|
62 | |
---|
63 | Note: do this as the "sanog" user! |
---|
64 | |
---|
65 | $ id |
---|
66 | uid=1001(sanog) gid=1001(sanog) groups=1001(sanog) |
---|
67 | |
---|
68 | $ mutt |
---|
69 | |
---|
70 | Mutt will ask you: |
---|
71 | |
---|
72 | /home/sanog/Mail does not exist. Create it? ([yes]/no): |
---|
73 | |
---|
74 | ... answer 'yes' |
---|
75 | |
---|
76 | You are now using "mutt", a simple mail client. You can use the arrows |
---|
77 | to move up and down, and press <RETURN> on a mail you want to read. |
---|
78 | |
---|
79 | You should be able to see the mail you sent to the sanog user. |
---|
80 | |
---|
81 | To quit: press 'q', and 'q' again to leave the program. |
---|
82 | |
---|
83 | Note: If you are lost, you can always press the '?' key to get help |
---|
84 | on using mutt. |
---|
85 | |
---|
86 | 5. Let's modify the /etc/aliases file, so we can receive mail for |
---|
87 | other system users into our mailbox: |
---|
88 | |
---|
89 | (As root!) |
---|
90 | |
---|
91 | # ee /etc/aliases (or vi /etc/aliases) |
---|
92 | |
---|
93 | Find the line: |
---|
94 | |
---|
95 | # root: me@my.domain |
---|
96 | |
---|
97 | And replace it with: |
---|
98 | |
---|
99 | root: sanog |
---|
100 | |
---|
101 | ... Look at the rest of the file, and look at the |
---|
102 | various system aliases. |
---|
103 | |
---|
104 | Save the file, and run the "newaliases" command: |
---|
105 | |
---|
106 | # newaliases |
---|
107 | # |
---|
108 | |
---|
109 | |
---|
110 | 6. Try sending mails to the "postmaster" user |
---|
111 | |
---|
112 | # echo "test to postmaster" | mail -s "test postmaster" postmaster@localhost |
---|
113 | |
---|
114 | Send another mail but this time, to operator@wsXX.ws3.conference.sanog.org |
---|
115 | |
---|
116 | ... replace "XX" with the number of your own PC, for example: |
---|
117 | |
---|
118 | # echo "test to my own machine" | mail -s "test operator" operator@wsXX.ws3.conference.sanog.org |
---|
119 | |
---|
120 | |
---|
121 | 7. Check that you received these mails |
---|
122 | |
---|
123 | $ mutt |
---|
124 | |
---|
125 | Check that all mails have been received |
---|
126 | |
---|
127 | A useful key is the 'h' key -- while displaying a mail, this will |
---|
128 | toggle between showing "full" headers, and limited headers. |
---|
129 | |
---|
130 | Use this feature to inspect the mails in your mailbox. |
---|
131 | |
---|
132 | Note the "To:" and "X-Original-To:" headers. |
---|
133 | |
---|
134 | |
---|
135 | 8. Send mail to other users in the class! |
---|
136 | |
---|
137 | Since you were able to send mail to your OWN machine, then you can also |
---|
138 | send mails to other users in the class: |
---|
139 | |
---|
140 | $ echo "hello from wsXX" | mail -s "mail from wsXX" sanog@wsYY.ws3.conference.sanog.org |
---|
141 | $ echo "hello from wsXX" | mail -s "mail from wsXX" sanog@wsZZ.ws3.conference.sanog.org |
---|
142 | |
---|
143 | ... where "XX" is yourself, YY and ZZ are other PCs in the room |
---|
144 | |
---|