{"id":122,"date":"2016-11-06T00:22:02","date_gmt":"2016-11-06T04:22:02","guid":{"rendered":"http:\/\/unliterate.net\/?p=122"},"modified":"2016-11-06T00:22:02","modified_gmt":"2016-11-06T04:22:02","slug":"sendmail-dovecot-how-do-you-work","status":"publish","type":"post","link":"https:\/\/www.unliterate.net\/index.php\/2016\/11\/06\/sendmail-dovecot-how-do-you-work\/","title":{"rendered":"sendmail &#038; dovecot: how do you work&#8230;"},"content":{"rendered":"<p style=\"text-align: left;\">So, I currently have the following on my VPS so that I can properly run my own mail server:<\/p>\n<ul>\n<li>sendmail: for SMTP mail<\/li>\n<li>dovecot: for POP3 mail<\/li>\n<\/ul>\n<p style=\"text-align: left;\">When I set them up, I made it so that I could emulate what I originally had through <a href=\"https:\/\/phpwebhosting.com\/\">phpwebhosting.com<\/a>, which was basically &#8220;all mail gets forwarded to one mail box, then that mail box is downloaded.&#8221;<\/p>\n<p style=\"text-align: left;\">So, since I use an internet service that prevents Port 25 connection, it renders my sendmail ability null and void.<\/p>\n<p style=\"text-align: left;\">I do know that I need to get TLS up and running so I can use that to connect to instead of standard SMTP to relay mail. I just need to figure out how to setup the mail servers again and how to configure it up so I don&#8217;t interrupt my production setup already. Sooo&#8230;.<\/p>\n<p><strong>Lets get things installed:<\/strong><\/p>\n<p>As usual, I use a minimal-installed Centos 6.8 system,\u00a0<em>yum upgrade<\/em>d, and no additional users. According to my documentation, i&#8217;ll need 3\u00a0things to\u00a0<em>yum install<\/em>:<\/p>\n<ul>\n<li>dovecot &#8211; a secure and highly configurable IMAP and POP3 server<\/li>\n<li>sendmail &#8211; an electronic mail transport agent<\/li>\n<li>saslauthd &#8211; sasl authentication server<\/li>\n<\/ul>\n<p>We need dovecot as the retrieval mechanism, and it won&#8217;t be configured just yet.<\/p>\n<p>We need sendmail to &#8230;. send email.<\/p>\n<p>We need saslauthd so that we can AUTH our sendmail instance, which allows us to not mail-proxy the world.<\/p>\n<pre>[root@mailboy ~]# yum install sendmail sendmail-cf cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain dovecot\r\nPackage cyrus-sasl-2.1.23-15.el6_6.2.x86_64 already installed and latest version\r\nResolving Dependencies\r\n--&gt; Running transaction check\r\n---&gt; Package sendmail.x86_64 0:8.14.4-9.el6_8.1 will be installed\r\n--&gt; Processing Dependency: procmail for package: sendmail-8.14.4-9.el6_8.1.x86_64\r\n--&gt; Processing Dependency: libhesiod.so.0()(64bit) for package: sendmail-8.14.4-9.el6_8.1.x86_64\r\n--&gt; Running transaction check\r\n---&gt; Package sendmail-cf.noarch 0:8.14.4-9.el6_8.1 will be installed\r\n--&gt; Running transaction check\r\n---&gt; Package hesiod.x86_64 0:3.1.0-19.el6 will be installed\r\n---&gt; Package procmail.x86_64 0:3.22-25.1.el6_5.1 will be installed\r\n--&gt; Running transaction check\r\n---&gt; Package cyrus-sasl-devel.x86_64 0:2.1.23-15.el6_6.2 will be installed\r\n---&gt; Package cyrus-sasl-gssapi.x86_64 0:2.1.23-15.el6_6.2 will be installed\r\n---&gt; Package cyrus-sasl-md5.x86_64 0:2.1.23-15.el6_6.2 will be installed\r\n---&gt; Package cyrus-sasl-plain.x86_64 0:2.1.23-15.el6_6.2 will be installed\r\n---&gt; Package dovecot.x86_64 1:2.0.9-22.el6 will be installed\r\n--&gt; Processing Dependency: portreserve for package: 1:dovecot-2.0.9-22.el6.x86_64\r\n--&gt; Running transaction check\r\n---&gt; Package portreserve.x86_64 0:0.0.4-11.el6 will be installed\r\n--&gt; Finished Dependency Resolution\r\n\r\nInstalled: sendmail.x86_64 0:8.14.4-9.el6_8.1 cyrus-sasl-devel.x86_64 0:2.1.23-15.el6_6.2 cyrus-sasl-gssapi.x86_64 0:2.1.23-15.el6_6.2 cyrus-sasl-md5.x86_64 0:2.1.23-15.el6_6.2 cyrus-sasl-plain.x86_64 0:2.1.23-15.el6_6.2 dovecot.x86_64 1:2.0.9-22.el6\r\n\r\nDependency Installed:\r\n hesiod.x86_64 0:3.1.0-19.el6 procmail.x86_64 0:3.22-25.1.el6_5.1 portreserve.x86_64 0:0.0.4-11.el6\r\n\r\nComplete!<\/pre>\n<p>And that takes care of 99% of everything we need! Just need to make sure we have our services:<\/p>\n<pre>[root@mailboy ~]# service sendmail status\r\nsendmail is stopped\r\nsm-client is stopped\r\n[root@mailboy ~]# service dovecot status\r\ndovecot is stopped\r\n[root@mailboy ~]# service saslauthd status\r\nsaslauthd is stopped\r\n[root@mailboy ~]#<\/pre>\n<p>Bingo!<\/p>\n<p><strong>Configuring Sendmail:<\/strong><\/p>\n<p>This&#8230;this is a pain in the ass. Get to \/etc\/mail, which is where sendmail claims its territory.<\/p>\n<p>So, the first thing we need to do is \/know\/ what we need to do. This can be pretty hard and daunting at the start, but i&#8217;ve seemed to break this down to a couple steps.<\/p>\n<p>Some configuration files are easy, plain-texty-types. Others are &#8220;learn M4, make, compile, pray&#8221;.<\/p>\n<p><span style=\"text-decoration: underline;\">local-host-names<\/span>: Easy plain-text list of all domains you are accepting mail from. There shouldn&#8217;t really be much aside from &#8220;Edit with favorite editor, then edit more and more&#8221;. A sample entry is as easy as <em>derpydoodles.com<\/em><\/p>\n<p><span style=\"text-decoration: underline;\">virtusertable<\/span>: This is the &#8220;who gets what mail, and where mail can go to&#8221; configuration. Before digging into this, I created a linux\u00a0<em>postyman<\/em> user to have all domains listed in the\u00a0<em>local-host-names<\/em> dump their mail to. Seemed pretty easy. The configuration to place into this file ended up being:<\/p>\n<pre># http:\/\/www.yolinux.com\/TUTORIALS\/Sendmail.html\r\n# File \/etc\/mail\/virtusertable (Optional) Allows the separation of emails by domain. i.e. greg@domain1.com and greg@domain2.com go to two different users greg1 and greg2.\r\n# webmaster@domain-1.com dave\r\n# webmaster@domain-2.com john\r\n# john@domain-2.com john\r\n# @domain-2.com error:nouser User unknown\r\n# @domain3.com mathew\r\n# The second column is the local user, a remote forwarding email address or a mailing list entry in \/etc\/aliases.\r\n########################################\r\n# NOTE: Check \/etc\/aliases to make sure that you dont use one there before putting it here\r\n########################################\r\n# Make all email to all domains below go to postmaster.\r\n\r\n@derpydoodles.com\u00a0postyman<\/pre>\n<p>After this configuration is done, we have to &#8220;build the database!&#8221;. This is sort-of easy:<\/p>\n<pre>makemap hash \/etc\/mail\/virtusertable &lt; \/etc\/mail\/virtusertable<\/pre>\n<p><span style=\"text-decoration: underline;\">sendmail.mc:<\/span> This is a son-of-a-doggie.<\/p>\n<p>So, the first thing is to get Authentication rolling up.\u00a0I&#8217;ve copy\/pasted the changes necessary to get &#8220;AUTH LOGIN&#8221; working for sendmail:<\/p>\n<p>Uncomment:<\/p>\n<pre>dnl #\r\n dnl # The following allows relaying if the user authenticates, and disallows\r\n dnl # plaintext authentication (PLAIN\/LOGIN) on non-TLS links\r\n dnl #\r\n define(`confAUTH_OPTIONS', `A p')dnl\r\n define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl\r\n TRUST_AUTH_MECH(`LOGIN PLAIN')dnl<\/pre>\n<p>Comment and Add:<\/p>\n<pre>dnl # TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl\r\n dnl # define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl\r\n define(`confAUTH_OPTIONS', `A')dnl\r\n define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl\r\n TRUST_AUTH_MECH(`LOGIN PLAIN')dnl\r\n dnl #<\/pre>\n<p>Comment and Modify:<\/p>\n<pre>dnl # The following causes sendmail to only listen on the IPv4 loopback address\r\n dnl # 127.0.0.1 and not on any other network devices. Remove the loopback\r\n dnl # address restriction to accept email from the internet or intranet.\r\n dnl #\r\n dnl #DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl\r\n DAEMON_OPTIONS(`Port=smtp,Name=MTA')dnl\r\n dnl #<\/pre>\n<p>And finally, allow the extra port for funsies:<\/p>\n<pre>DAEMON_OPTIONS(`Port=587, Name=MSA, M=E')dnl<\/pre>\n<p>And then we need to &#8220;compile&#8221; this out&#8230;<\/p>\n<pre>m4 \/etc\/mail\/sendmail.mc &gt; \/etc\/mail\/sendmail.cf<\/pre>\n<p>Start some services:<\/p>\n<pre>[root@mailboy mail]# service saslauthd start\r\nStarting saslauthd: [ OK ]\r\n[root@mailboy mail]# service sendmail start\r\nStarting sendmail: [ OK ]\r\nStarting sm-client: [ OK ]\r\n[root@mailboy mail]#<\/pre>\n<p>And testing:<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I currently have the following on my VPS so that I can properly run my own mail server: sendmail: for SMTP mail dovecot: for POP3 mail When I set them up, I made it so that I could emulate what I originally had through phpwebhosting.com, which was basically &#8220;all mail gets forwarded to one [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-random"],"_links":{"self":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":9,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/122\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}