{"id":402,"date":"2006-08-26T23:59:07","date_gmt":"2006-08-26T23:59:07","guid":{"rendered":"http:\/\/www.odrakir.com\/blog\/?p=402"},"modified":"2006-08-27T00:03:03","modified_gmt":"2006-08-27T00:03:03","slug":"your-own-personal-mail-server","status":"publish","type":"post","link":"https:\/\/www.odrakir.com\/blog\/2006\/08\/26\/your-own-personal-mail-server\/","title":{"rendered":"Your Own Personal Mail Server"},"content":{"rendered":"<p>Are you sick of having all your mail spread arround on your computers? When you have more than one pc, or even if you check your email at work and then at home, it&#8217;s a nightmare to keep track of so many emails. And if you&#8217;re like me, I have multiple mail accounts, meaning more mail from diferent sources, well the solution isn&#8217;t spending all your day sending mail back and forward from one account to another. The solution is actually preety simple: <a href=\"http:\/\/en.wikipedia.org\/wiki\/Internet_Message_Access_Protocol\">IMAP<\/a>!<\/p>\n<p>This how to covers <a href=\"http:\/\/www.ubuntu.com\/server\">Ubuntu 6.06 Server<\/a> (yes the server version of Ubuntu duh!) but it&#8217;s preety simple to adapt to other distros. Let&#8217;s start!<\/p>\n<p><strong>Be warned that you may loose some email messages in the process so test this first with a dummy account!<\/strong><\/p>\n<p>Assuming you have Ubuntu installed and updated, open a shell and type:<br \/>\n<code><br \/>\nmkdir Maildir<\/code> (create this on your home folder)<\/p>\n<p><code>sudo apt-get install dovecot<\/code><\/p>\n<p>Let it install all the packages need for dependecies.<\/p>\n<p><a href=\"http:\/\/www.dovecot.org\/\">Dovecot<\/a> is an open source IMAP and POP3 server, is very simple to install \/ configure and suports the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Maildir\">Maildir<\/a> format which is a standard and the one we&#8217;re going to use. Dovecot is very complete and has <a href=\"http:\/\/wiki.dovecot.org\/MainConfig\">several options<\/a>, most of them related to security, I&#8217;m not covering those so feel free to <a href=\"http:\/\/wiki.dovecot.org\/\">explore<\/a>.<\/p>\n<p>So, back to the shell and enter:<\/p>\n<p><code>sudo nano \/etc\/dovecot\/dovecot.conf<\/code><\/p>\n<p>Now change the following:<\/p>\n<p><code># Protocols we want to be serving:<br \/>\n#  imap imaps pop3 pop3s<br \/>\n#protocols = imap imaps<br \/>\n#protocols = imap imaps<\/code><\/p>\n<p>to<\/p>\n<p><code># Protocols we want to be serving:<br \/>\n#  imap imaps pop3 pop3s<br \/>\n#protocols = imap imaps<br \/>\nprotocols = imap imaps<\/code><\/p>\n<p>Save the file and run dovecot:<\/p>\n<p><code>sudo \/usr\/sbin\/dovecot<\/code><\/p>\n<p>And now test your IMAP Server:<\/p>\n<p><code>mutt -f imap:\/\/yourusername@localhost<\/code><\/p>\n<p>You should get a little nagging about the certificates but after that you enter your password and you should be able to see your empty IMAP folder.<\/p>\n<p>Now the next part is to get the email from the other accounts and for this we&#8217;re using a little app named <a href=\"http:\/\/pyropus.ca\/software\/getmail\/\">Getmail<\/a>. Getmail can check your POP and IMAP accounts, I&#8217;ll cover only the POP accounts but there&#8217;s some examples you can check. Getmail also features some very usefull mail sorting options you can check later.<\/p>\n<p>So, if you&#8217;re using Ubuntu 6.06 &#8220;normal&#8221; then you should be able to download Getmail via apt-get:<\/p>\n<p><code>sudo apt-get install getmail<\/code><\/p>\n<p>If you&#8217;re using the Ubuntu server version you won&#8217;t get this package via apt-get unless you add the right repository or download the package and install it manually:<\/p>\n<p><code><\/p>\n<p>wget http:\/\/archive.ubuntu.com\/ubuntu\/pool\/universe\/g\/getmail4\/getmail4_4.4.3-1_all.deb<\/code><\/p>\n<p><code>dpkg -i getmail4_4.4.3-1_all.deb<\/code><\/p>\n<p>Now comes the lame part \ud83d\ude1b<\/p>\n<p>You&#8217;ll have to write a little configuration file for each of the POP \/ IMAP accounts you want to check. I&#8217;m going to give you an example for a regular POP account and for a GMAIL account.<\/p>\n<p>Again, back to the shell and type:<\/p>\n<p><code>cd<br \/>\ncd .getmail<br \/>\ntouch gmailrc<br \/>\nsudo nano gmailrc<\/code><\/p>\n<p>The configuration file for a GMAIL account:<\/p>\n<p><code>[retriever]<br \/>\ntype = SimplePOP3SSLRetriever<br \/>\nserver = pop.gmail.com<br \/>\nport = 995<br \/>\nusername = yourusername@gmail.com<br \/>\npassword = yourpassword<\/p>\n<p>[destination]<br \/>\ntype = Maildir<br \/>\npath = ~yourhomedirectory\/Maildir\/<\/p>\n<p>[options]<br \/>\ndelete = true<\/code><\/p>\n<p>Save it and repeat the process for a regular POP account:<\/p>\n<p><code>touch ispmailrc<br \/>\nsudo nano ispmailrc<\/p>\n<p>[retriever]<br \/>\ntype = SimplePOP3Retriever<br \/>\nserver = pop3.myisp.com<br \/>\nusername = yourusername@myisp.com<br \/>\npassword = yourpassword<\/p>\n<p>[destination]<br \/>\ntype = Maildir<br \/>\npath = ~yourhomedirectory\/Maildir\/<\/p>\n<p>[options]<br \/>\ndelete = true<\/code><\/p>\n<p>Save and test it:<\/p>\n<p><code>sudo \/usr\/bin\/getmail --rcfile=gmailrc<\/code><\/p>\n<p>If all goes well you&#8217;ll get a few messages like this:<\/p>\n<p><code>getmail version 4.4.3<br \/>\nCopyright (C) 1998-2005 Charles Cazabon.  Licensed under the GNU GPL version 2.<br \/>\nSimplePOP3SSLRetriever:username@gmail.com@pop.gmail.com:995:<br \/>\n  0 messages retrieved, 0 skipped<\/code><\/p>\n<p>This means Getmail is working, now send yourself some messages to your accounts to test it and run getmail again to check if it delivers to your IMAP folders. You can check it using Mutt like we did earlier.<\/p>\n<p>By now everything should be working perfectly, we just have to automate the email checking. Let&#8217;s use crontab. Go to the shell and enter:<\/p>\n<p><code>crontab -e<\/code><\/p>\n<p>Now copy this line and save the file:<\/p>\n<p><code>* * * * * \/usr\/bin\/getmail --rcfile=gmailrc --rcfile=ispmailrc >> \/dev\/null 2>&1<\/code><\/p>\n<p><strong>(this has to be all in one line, don&#8217;t break it or it won&#8217;t work correctly!)<\/strong><\/p>\n<p>And we&#8217;re done! Now use an IMAP compatible client like Mozilla Thunderbir or Evolution and you&#8217;ll never have to worry with email again.<\/p>\n<p>[tags]IMAP, POP, E-Mail, Email, GMail, Personal Mail Server, Linux, Ubuntu, Ubuntu Server, Getmail, Dovecot[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you sick of having all your mail spread arround on your computers? When you have more than one pc, or even if you check your email at work and then at home, it&#8217;s a nightmare to keep track of so many emails. And if you&#8217;re like me, I have multiple mail accounts, meaning more [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,10],"tags":[],"class_list":["post-402","post","type-post","status-publish","format-standard","hentry","category-linux","category-networking"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/posts\/402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/comments?post=402"}],"version-history":[{"count":0,"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/posts\/402\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/media?parent=402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/categories?post=402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.odrakir.com\/blog\/wp-json\/wp\/v2\/tags?post=402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}