| 1 | ENABLING MAILDIR, CONFIGURING IMAP AND POP |
|---|
| 2 | ------------------------------------------ |
|---|
| 3 | |
|---|
| 4 | 1. Edit the file "main.cf" (using vi or ee) |
|---|
| 5 | |
|---|
| 6 | Add the following lines to main.cf: |
|---|
| 7 | |
|---|
| 8 | home_mailbox = Maildir/ |
|---|
| 9 | |
|---|
| 10 | 2. Create a Maildir folder for the sysadm user: |
|---|
| 11 | |
|---|
| 12 | (DO THIS AS THE SANOG USER!) |
|---|
| 13 | |
|---|
| 14 | $ mkdir /home/sysadm/Maildir |
|---|
| 15 | |
|---|
| 16 | Note: if you do not do this as the sysadm user, |
|---|
| 17 | the mail system will NOT be able to deliver mail. |
|---|
| 18 | |
|---|
| 19 | 3. Try sendmail mail again to your domain: |
|---|
| 20 | |
|---|
| 21 | $ echo "test with maildir" | mail -s "test maildir" sysadm@MYNAME.ws.nsrc.org |
|---|
| 22 | |
|---|
| 23 | * Now, run mutt again: |
|---|
| 24 | |
|---|
| 25 | $ mutt |
|---|
| 26 | |
|---|
| 27 | ... do you see your mail ? |
|---|
| 28 | |
|---|
| 29 | No, the reason is that now the mail is not stored in /var/mail, |
|---|
| 30 | but in the "Maildir/" directory in your home dir. |
|---|
| 31 | |
|---|
| 32 | To access it, first quit mutt ('q'), then relaunch mutt like this: |
|---|
| 33 | |
|---|
| 34 | $ mutt -f ~sysadm/Maildir/ |
|---|
| 35 | |
|---|
| 36 | ... this explicitly tells mutt to access the "Maildir" in the |
|---|
| 37 | home (~) directory of the user "sysadm". |
|---|
| 38 | |
|---|
| 39 | Why Maildir ? It's a better mail storage format when many mails |
|---|
| 40 | need to be accessed quickly - one email / file on the disk. |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | But what if you want to read your mail remotely ? |
|---|
| 44 | |
|---|
| 45 | 4. Install and configure the Courier IMAP daemon |
|---|
| 46 | |
|---|
| 47 | # apt-get install courier-imap |
|---|
| 48 | |
|---|
| 49 | When asked about the web-enabled configuration file, say NO |
|---|
| 50 | |
|---|
| 51 | It should now be started! |
|---|
| 52 | |
|---|
| 53 | 5. You may now use mutt to read your mail via POP, and IMAP |
|---|
| 54 | |
|---|
| 55 | * First, tell mutt NOT to attempt SSL negotiation: |
|---|
| 56 | |
|---|
| 57 | $ echo 'set ssl_starttls = no' > /home/sysadm/.muttrc |
|---|
| 58 | |
|---|
| 59 | (We have not configured an SSL certificate yet, therefore we need |
|---|
| 60 | to disable this option for the time being) |
|---|
| 61 | |
|---|
| 62 | Now, run mutt: |
|---|
| 63 | |
|---|
| 64 | POP: |
|---|
| 65 | |
|---|
| 66 | $ mutt -f pop://sysadm@pcX (where pcX is your own machine) |
|---|
| 67 | Password for sysadm@pcX: |
|---|
| 68 | |
|---|
| 69 | IMAP: |
|---|
| 70 | |
|---|
| 71 | $ mutt -f imap://sysadm@pcX (where pcX is your own machine) |
|---|
| 72 | Password for sysadm@pcX: |
|---|
| 73 | |
|---|
| 74 | ... you can now read your mail remotely, and you can also read mail |
|---|
| 75 | on other machines: |
|---|
| 76 | |
|---|
| 77 | $ mutt -f pop://sysadm@pcY (where pcY is another machine in the room) |
|---|
| 78 | or |
|---|
| 79 | $ mutt -f imap://sysadm@pcY (where pcY is another machine in the room) |
|---|
| 80 | |
|---|
| 81 | 6. Open another window (or terminal), and log in as 'root'. |
|---|
| 82 | |
|---|
| 83 | * Now, run tcpdump so you can see the contents of the traffic on |
|---|
| 84 | the POP (110) and IMAP (143) ports: |
|---|
| 85 | |
|---|
| 86 | # tcpdump -X -s0 -n port 143 or port 110 |
|---|
| 87 | |
|---|
| 88 | * Now ask someone else to read mail on YOUR server |
|---|
| 89 | |
|---|
| 90 | * What do you observe in the tcpdump window ? |
|---|
| 91 | |
|---|
| 92 | 7. Try to setup your mail program on your laptop (Outlook, Thunderbird, ...) to |
|---|
| 93 | read mail on your newly installed POP/IMAP server! |
|---|