{"id":1791,"date":"2014-02-11T15:09:36","date_gmt":"2014-02-11T13:09:36","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=1791"},"modified":"2014-02-11T19:37:02","modified_gmt":"2014-02-11T17:37:02","slug":"installing-postfix-and-configure-smarthost-for-use-with-exchange","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=1791","title":{"rendered":"Ubuntu Postfix and Drupal configure Mail smarthost with Exchange."},"content":{"rendered":"<p>Consider a situation in which you have installed Drupal in your Ubuntu machine. Now you would like to start sending email from localhost.If you have not setup Mail Transfer Agent(MTA) than you will not be able to send email from localhost.\u00a0To make it simple, MTA is the tool you require to transfer mail from localhost.<\/p>\n<h2>Installing Postfix :<\/h2>\n<ol>\n<li>Check weather postfix is install in your system. Type following in Terminal.\n<pre>postfix --version<\/pre>\n<\/li>\n<li>If you get this message than postfix is not installed.<br \/>\n<blockquote><p>The program &#8216;postfix&#8217; is currently not installed.\u00a0 You can install it by typing:<\/p>\n<pre>apt-get install postfix<\/pre>\n<\/blockquote>\n<\/li>\n<li>if it is installed, you can reconfigure <strong>postfix<\/strong>:\n<pre>sudo dpkg-reconfigure postfix<\/pre>\n<\/li>\n<li>Select \u201cInternet with smarthost\u201d. I\u2019m using this setting as I\u2019m going to send mail through my Exchange mail server. <a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/02\/ubuntu-drupal.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1792\" alt=\"ubuntu-drupal\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/02\/ubuntu-drupal.png\" width=\"300\" height=\"212\" \/><\/a><\/li>\n<li>\u00a0Type Domain name. Since our user will be named \u201cRancid\u201d and the mail domain will be \u201cdomain.local\u201d, we will type in:\n<pre>\u00a0domain.local<\/pre>\n<p>&nbsp;<\/li>\n<li>Enther the FQDN or IP of the smarthost, you can also define a custom port like port 26, like this <strong>host:port<\/strong>\n<ol>\n<li>Our Exchange FQDN is:\n<pre> EXCH2010.domain.local<\/pre>\n<\/li>\n<li>That\u2019s it. <strong>We have set up anonymous no-authentication mailrelay up<\/strong>. Now we have to setup the Exchange-server to accept these relays.<br \/>\nThats all with postfix configuration. Now restart your apache server.<\/p>\n<pre>sudo service apache2 restart<\/pre>\n<\/li>\n<li>Time to test if it Works (ping server and telnet on port 25) :\n<pre>myserver@myserver:~$ telnet localhost 25\r\n Trying 127.0.0.1...\r\n Connected to localhost.\r\n Escape character is '^]'.\r\n 220 myserver ESMTP Postfix (Ubuntu)\r\n helo myserver.domain.local\r\n 250 myserver\r\n mail from: myserver@domain.local\r\n 250 2.1.0 Ok\r\n rcpt to: receiver@domain.local\r\n 250 2.1.5 Ok\r\n data\r\n 354 End data with .\r\n Hi,\r\n This is test mail. Sent from Postfix linux server.\r\n smart host relay configuration.\r\n Thanks!!!\r\n .\r\n 250 2.0.0 Ok: queued as xxxxxxxx\r\n quit\r\n 221 2.0.0 Bye\r\n Connection closed by foreign host.\r\n myserver@myserver:~$<\/pre>\n<\/li>\n<li>If you are having issues with mail not popping up in your mailbox, you should review the settings using:\n<pre> sudo nano \/etc\/postfix\/main.cf<\/pre>\n<\/li>\n<li>You must check also log mail files under : <strong>\/var\/log\/mail.*<\/strong> : All mail server message log files (<strong>Ubuntu use postfix mail sending by default)<\/strong>.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h2>Command Line for mail:<\/h2>\n<p>The main command to check if you have mail is <strong>mail<\/strong>. Run the command below, replacing &#8220;user@yourmaildomain.com&#8221; with your e-mail address. The s option specifies the subject of the mail followed by the recipient email address.<\/p>\n<pre>$ mail -s \"Hello World\" user@yourmaildomain.com<\/pre>\n<p>Now you have to type in your message. When you&#8217;re done, hit \u2018<strong>control-D<\/strong>\u2019 at the beginning of a line<\/p>\n<pre># mail -s \"This is the subject\" m00n.silv3r@gmail.com\r\nCc: \r\nHi Silver\r\nHow are you doing\r\nHope its going fine.\r\nBye<\/pre>\n<p>Now, the first mail is sent on command line. The content of the mail can be taken from a file as follows:<\/p>\n<p>In some distributions, the shell asks other fields interactively like &#8216;Cc&#8217; (Carbon copy) first. Just hit enter here to skip. Next type in your message. When you enter the mail address or addresses with commas, you need to press enter to go to the new line for message body.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Other useful parameters in the mail command are <\/strong>:<\/p>\n<p>-s subject (The subject of the mail)<br \/>\n-c email-address (CC &#8211; send a carbon copy to email-address)<br \/>\n-b email-address (BCC &#8211; send a blind carbon copy to email-address)<\/p>\n<p>Here&#8217;s and example of how you might use these options<\/p>\n<pre>$ mail -s \"Hello World\" user@yourmaildomain.com -c usertocc@yourmaildomain.com -b usertobcc@yourmaildomain.com<\/pre>\n<p>It is also possible to specify multiple recipients by joining them with a comma.<\/p>\n<pre>$ mail -s \"Hello World\" user1@yourmaildomain.com,user2@yourmaildomain.com<\/pre>\n<h3 >Some Useful Commands for postfix :<\/h3>\n<ul>\n<li>Reconfigure postfix: sudo dpkg-reconfigure postfix<\/li>\n<li>Remove Postfix completely: sudo apt-get purge postfix<\/li>\n<li>Check mail log : nano\/var\/log\/mail.log<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Consider a situation in which you have installed Drupal in your Ubuntu machine. Now you would like to start sending email from localhost.If you have not setup Mail Transfer Agent(MTA) than you will not&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2843,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[139,209,14],"tags":[268,269,270],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1791"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1791"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1791\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2843"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}