{"id":237,"date":"2011-11-07T02:23:52","date_gmt":"2011-11-07T08:23:52","guid":{"rendered":"http:\/\/www.n8williams.com\/devblog\/?p=237"},"modified":"2011-11-07T02:23:52","modified_gmt":"2011-11-07T08:23:52","slug":"using-postfix-on-linux-for-sending-only-outgoing-messages","status":"publish","type":"post","link":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages","title":{"rendered":"Using postfix on linux for sending only outgoing messages"},"content":{"rendered":"<p>Summary: What you want is to set up a null client. http:\/\/www.postfix.org\/faq.html#null_client See my notes below for what constitutes an \u2019smtp server entry\u2019.<\/p>\n<p>So for my local dev environments I\u2019ve been in the habit of setting up php\u2019s mail function to work by doing a \u2019sudo apt-get install sendmail\u2019 and editing the php.ini to point the sendmail_path to \/usr\/sbin\/sendmail. (I\u2019d recommend this procedure only if you\u2019re working locally and don\u2019t plan on opening port 25 to anything public, won\u2019t want to mess with domain names, and won\u2019t be dealing with mx records, etc.).<\/p>\n<p>Well when I actually had to setup a server with a public domain, and needed emails to work efficiently from php with a qualified domain while worrying about port 25 being secure, I was in for some fun. For starters I\u2019d recommend postfix over sendmail. Much easier to configure. Sendmail has many more config files, and you have to re-compile some of them after edits, etc. So once you have postfix installed, if you just want to send outgoing emails, then you can increase security and reduce overhead by making postfix not listen on the SMTP port. I wanted postfix as an smtp client only. With sendmail you can do this, and even kill all the daemons. With postfix you still need the daemon going, but when we\u2019re done, nothing will be listening on port 25, smtp.<\/p>\n<p>So what we are setting up is called a \u2018null client\u2019. You just have to modify \/etc\/postfix\/main.cf and master\/cf according to the instructions at http:\/\/www.postfix.org\/faq.html#null_client.<\/p>\n<p>The main thing that was unclear to me is what line(s) constitute a \u2018SMTP server entry\u2019 in master.cf. After commenting out the line close to the top with \u2019service\u2019 as \u2019smtp\u2019 and \u2018type\u2019 as \u2018inet\u2019, I figured this was enough, as \u2019sudo lsof -i\u2019 indicated nothing was listening on port 25, or as smtp. I would leave the other smtp service entries alone, the ones with \u2018type\u2019 as \u2018unix\u2019.<\/p>\n<p>Then do \u2019sudo postfix reload\u2019 and for good measure we may as well do \u2019sudo \/etc\/init.d\/postfix restart\u2019, or the equivalent on your linux distro.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: What you want is to set up a null client. http:\/\/www.postfix.org\/faq.html#null_client See my notes below for what constitutes an \u2019smtp server entry\u2019. So for my local dev environments I\u2019ve been in the habit of setting up php\u2019s mail function to work by doing a \u2019sudo apt-get install sendmail\u2019 and editing the php.ini to point &hellip; <a href=\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using postfix on linux for sending only outgoing messages&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using postfix on linux for sending only outgoing messages - The Dev Pages<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using postfix on linux for sending only outgoing messages - The Dev Pages\" \/>\n<meta property=\"og:description\" content=\"Summary: What you want is to set up a null client. http:\/\/www.postfix.org\/faq.html#null_client See my notes below for what constitutes an \u2019smtp server entry\u2019. So for my local dev environments I\u2019ve been in the habit of setting up php\u2019s mail function to work by doing a \u2019sudo apt-get install sendmail\u2019 and editing the php.ini to point &hellip; Continue reading &quot;Using postfix on linux for sending only outgoing messages&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\" \/>\n<meta property=\"og:site_name\" content=\"The Dev Pages\" \/>\n<meta property=\"article:published_time\" content=\"2011-11-07T08:23:52+00:00\" \/>\n<meta name=\"author\" content=\"Nate Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@admin\" \/>\n<meta name=\"twitter:site\" content=\"@admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nate Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#article\",\"isPartOf\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\"},\"author\":{\"name\":\"Nate Admin\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"headline\":\"Using postfix on linux for sending only outgoing messages\",\"datePublished\":\"2011-11-07T08:23:52+00:00\",\"dateModified\":\"2011-11-07T08:23:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\"},\"wordCount\":389,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"articleSection\":[\"General Dev\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\",\"url\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\",\"name\":\"Using postfix on linux for sending only outgoing messages - The Dev Pages\",\"isPartOf\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#website\"},\"datePublished\":\"2011-11-07T08:23:52+00:00\",\"dateModified\":\"2011-11-07T08:23:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/n8williams.com\/devblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using postfix on linux for sending only outgoing messages\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#website\",\"url\":\"https:\/\/n8williams.com\/devblog\/\",\"name\":\"The Dev Pages\",\"description\":\"A knowledge base for web applications development (and beyond)\",\"publisher\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/n8williams.com\/devblog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757\",\"name\":\"Nate Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g\",\"caption\":\"Nate Admin\"},\"logo\":{\"@id\":\"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/n8williams.com\",\"https:\/\/twitter.com\/admin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using postfix on linux for sending only outgoing messages - The Dev Pages","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages","og_locale":"en_US","og_type":"article","og_title":"Using postfix on linux for sending only outgoing messages - The Dev Pages","og_description":"Summary: What you want is to set up a null client. http:\/\/www.postfix.org\/faq.html#null_client See my notes below for what constitutes an \u2019smtp server entry\u2019. So for my local dev environments I\u2019ve been in the habit of setting up php\u2019s mail function to work by doing a \u2019sudo apt-get install sendmail\u2019 and editing the php.ini to point &hellip; Continue reading \"Using postfix on linux for sending only outgoing messages\"","og_url":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages","og_site_name":"The Dev Pages","article_published_time":"2011-11-07T08:23:52+00:00","author":"Nate Admin","twitter_card":"summary_large_image","twitter_creator":"@admin","twitter_site":"@admin","twitter_misc":{"Written by":"Nate Admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#article","isPartOf":{"@id":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages"},"author":{"name":"Nate Admin","@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"headline":"Using postfix on linux for sending only outgoing messages","datePublished":"2011-11-07T08:23:52+00:00","dateModified":"2011-11-07T08:23:52+00:00","mainEntityOfPage":{"@id":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages"},"wordCount":389,"commentCount":0,"publisher":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"articleSection":["General Dev"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#respond"]}]},{"@type":"WebPage","@id":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages","url":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages","name":"Using postfix on linux for sending only outgoing messages - The Dev Pages","isPartOf":{"@id":"https:\/\/n8williams.com\/devblog\/#website"},"datePublished":"2011-11-07T08:23:52+00:00","dateModified":"2011-11-07T08:23:52+00:00","breadcrumb":{"@id":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/n8williams.com\/devblog\/general_dev\/using-postfix-on-linux-for-sending-only-outgoing-messages#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/n8williams.com\/devblog\/"},{"@type":"ListItem","position":2,"name":"Using postfix on linux for sending only outgoing messages"}]},{"@type":"WebSite","@id":"https:\/\/n8williams.com\/devblog\/#website","url":"https:\/\/n8williams.com\/devblog\/","name":"The Dev Pages","description":"A knowledge base for web applications development (and beyond)","publisher":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/n8williams.com\/devblog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/1c31624786b5382f1a811f0a01985757","name":"Nate Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19d7bc7602072ac846e912622704a628?s=96&d=mm&r=g","caption":"Nate Admin"},"logo":{"@id":"https:\/\/n8williams.com\/devblog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/n8williams.com","https:\/\/twitter.com\/admin"]}]}},"_links":{"self":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/237"}],"collection":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":2,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":239,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/posts\/237\/revisions\/239"}],"wp:attachment":[{"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/n8williams.com\/devblog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}