{"id":398,"date":"2013-03-03T22:35:48","date_gmt":"2013-03-03T21:35:48","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=398"},"modified":"2014-08-24T13:21:01","modified_gmt":"2014-08-24T11:21:01","slug":"srv-mail","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=398","title":{"rendered":"srv-mail"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Prerequiste\"><span class=\"toc_number toc_depth_1\">1<\/span> Prerequiste<\/a><\/li><li><a href=\"#SMTP\"><span class=\"toc_number toc_depth_1\">2<\/span> SMTP<\/a><\/li><li><a href=\"#Testing_email\"><span class=\"toc_number toc_depth_1\">3<\/span> Testing email<\/a><ul><li><a href=\"#Inside_the_server\"><span class=\"toc_number toc_depth_2\">3.1<\/span> Inside the server<\/a><\/li><li><a href=\"#Outside_the_server\"><span class=\"toc_number toc_depth_2\">3.2<\/span> Outside the server<\/a><\/li><\/ul><\/li><li><a href=\"#IMAP_POP\"><span class=\"toc_number toc_depth_1\">4<\/span> IMAP \/ POP<\/a><\/li><\/ul><\/div>\n<h1><span id=\"Prerequiste\">Prerequiste<\/span><\/h1>\n<p>I assume that you have a Centos installation.<\/p>\n<h1><span id=\"SMTP\">SMTP<\/span><\/h1>\n<p>You can copy\/paste this script and use it to configure automatically your server.<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\"><ol><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #666666; font-style: italic;\">#!\/bin\/bash<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;install postfix&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">dnf <span style=\"color: #660033;\">-y<\/span> <span style=\"color: #c20cb9; font-weight: bold;\">install<\/span> postfix<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">dnf <span style=\"color: #660033;\">-y<\/span> remove <span style=\"color: #c20cb9; font-weight: bold;\">sendmail<\/span> <span style=\"color: #666666; font-style: italic;\"># make postfix the default MTA<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;start service&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">systemctl start postfix.service<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;configure postfix&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #666666; font-style: italic;\"># comments all:<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #c20cb9; font-weight: bold;\">sed<\/span> <span style=\"color: #660033;\">-i<\/span> <span style=\"color: #ff0000;\">&quot;s\/^\\(inet_interfaces = \\)\/#\\1\/&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>etc<span style=\"color: #000000; font-weight: bold;\">\/<\/span>postfix<span style=\"color: #000000; font-weight: bold;\">\/<\/span>main.cf<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #c20cb9; font-weight: bold;\">sed<\/span> <span style=\"color: #660033;\">-i<\/span> <span style=\"color: #ff0000;\">&quot;s\/^\\(mydestination = \\)\/#\\1\/&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>etc<span style=\"color: #000000; font-weight: bold;\">\/<\/span>postfix<span style=\"color: #000000; font-weight: bold;\">\/<\/span>main.cf<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #666666; font-style: italic;\"># remove comments:<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #c20cb9; font-weight: bold;\">sed<\/span> <span style=\"color: #660033;\">-i<\/span> <span style=\"color: #ff0000;\">&quot;s\/^#\\(inet_interfaces = all\\)\/\\1\/&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>etc<span style=\"color: #000000; font-weight: bold;\">\/<\/span>postfix<span style=\"color: #000000; font-weight: bold;\">\/<\/span>main.cf<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #c20cb9; font-weight: bold;\">sed<\/span> <span style=\"color: #660033;\">-i<\/span> <span style=\"color: #ff0000;\">&quot;s\/^#\\(home_mailbox = Maildir\\\/\\)\/\\1\/&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>etc<span style=\"color: #000000; font-weight: bold;\">\/<\/span>postfix<span style=\"color: #000000; font-weight: bold;\">\/<\/span>main.cf<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #c20cb9; font-weight: bold;\">sed<\/span> <span style=\"color: #660033;\">-i<\/span> <span style=\"color: #ff0000;\">&quot;s\/^#\\(mydestination = <span style=\"color: #000099; font-weight: bold;\">\\$<\/span>myhostname, localhost.<span style=\"color: #000099; font-weight: bold;\">\\$<\/span>mydomain, localhost, <span style=\"color: #000099; font-weight: bold;\">\\$<\/span>mydomain\\)$\/\\1\/&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>etc<span style=\"color: #000000; font-weight: bold;\">\/<\/span>postfix<span style=\"color: #000000; font-weight: bold;\">\/<\/span>main.cf<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;reload postfix&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">systemctl reload postfix.service<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;add service smtp (port 25) to firewall&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">firewall-cmd <span style=\"color: #660033;\">--permanent<\/span> <span style=\"color: #660033;\">--add-service<\/span> smtp<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">firewall-cmd <span style=\"color: #660033;\">--reload<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><\/ol><\/pre>\n<h1><span id=\"Testing_email\">Testing email<\/span><\/h1>\n<h2><span id=\"Inside_the_server\">Inside the server<\/span><\/h2>\n<p>First, we create our email file &#8217;email.txt&#8217;:<\/p>\n<pre>\r\nSubject: my subject\r\nmy message\r\n<\/pre>\n<p>Then, send it:<\/p>\n<pre lang=\"bash\">\r\nsendmail -v example@gmail.com < email.txt\r\n<\/pre>\n<h2><span id=\"Outside_the_server\">Outside the server<\/span><\/h2>\n<pre lang=\"bash\">\r\n$> telnet srv-mail 25\r\n$> \r\nhelo srv-mail\r\nmail from:<noreply@gmail.com>\r\nrcpt to:<my-email@gmail.com>\r\ndata\r\nFrom: noreply@gmail.com\r\nSubject: test mail from command line\r\n\r\nthis is my tiny message\r\nsent from linux\r\n.\r\n<\/pre>\n<h1><span id=\"IMAP_POP\">IMAP \/ POP<\/span><\/h1>\n<p>You can copy\/paste this script and use it to configure automatically your server.<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\"><ol><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #666666; font-style: italic;\">#!\/bin\/bash<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;install dovecot&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">dnf <span style=\"color: #660033;\">-y<\/span> <span style=\"color: #c20cb9; font-weight: bold;\">install<\/span> dovecot<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;configure dovecot&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #c20cb9; font-weight: bold;\">sed<\/span> <span style=\"color: #660033;\">-i<\/span> <span style=\"color: #ff0000;\">&quot;s\/^#\\(protocols\\s*=\\)\/\\1\/&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>etc<span style=\"color: #000000; font-weight: bold;\">\/<\/span>dovecot<span style=\"color: #000000; font-weight: bold;\">\/<\/span>dovecot.conf<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;start service dovecot on boot&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">systemctl <span style=\"color: #7a0874; font-weight: bold;\">enable<\/span> dovecot.service<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;start service&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">systemctl start dovecot.service<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;open pop3 port (i.e 110) and imap (i.e. 143)&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">firewall-cmd <span style=\"color: #660033;\">--permanent<\/span> <span style=\"color: #660033;\">--add-service<\/span> dovecot<\/div><\/li><\/ol><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 Prerequiste2 SMTP3 Testing email3.1 Inside the server3.2 Outside the server4 IMAP \/ POP Prerequiste I assume that you have a Centos installation. SMTP You can copy\/paste this script and use it to configure automatically your server. Testing email Inside the server First, we create our email file &#8217;email.txt&#8217;: Subject: my subject my message Then, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":677,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-398","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=398"}],"version-history":[{"count":18,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/398\/revisions"}],"predecessor-version":[{"id":1208,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/398\/revisions\/1208"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/677"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}