{"id":402,"date":"2017-01-02T09:45:05","date_gmt":"2017-01-02T07:45:05","guid":{"rendered":"http:\/\/www.geohei.lu\/geoheiWP\/?p=402"},"modified":"2019-06-27T10:57:55","modified_gmt":"2019-06-27T08:57:55","slug":"null-client-postfix-setup","status":"publish","type":"post","link":"https:\/\/www.geohei.lu\/geoheiWP\/null-client-postfix-setup\/","title":{"rendered":"Null client Postfix setup"},"content":{"rendered":"<p><code><br \/>\nThe following setup describes a postix setup to send e-mails using an existing SMTP server. It is not designed to receive e-mails. My provider is DreamHost, but setup should be very similar with other hosters. I used a VM with the Ubuntu Server 16.04.1 out of the box installtion (ubuntu-16.04.1-server-amd64). This VM has no real FQDN, hence an imaginary needs to be configured in order to make the SMPT server accept sent e-mails.<\/p>\n<p><!--more--><\/p>\n<p>These packages are required, but might be installed already. <\/p>\n<pre>root@vmtest:~# apt-get install libsasl2-modules\r\nReading package lists... Done\r\nBuilding dependency tree\r\nReading state information... Done\r\nlibsasl2-modules is already the newest version (2.1.26.dfsg1-14build1).\r\n0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.<\/pre>\n<p><br \\><\/p>\n<p>Installation of the utility \"mail\" is desired and\/or necessary (used here for testing only). <\/p>\n<pre>root@vmtest:~# apt-get install mailutils<\/pre>\n<p><br \\><\/p>\n<p>Install postfix. Select \"Internet Site\" (General type of mail configuration:) and enter \"vmtest.mydomain.local\" (System mail name:) as domainname.<\/p>\n<pre>root@vmtest:~# apt-get install postfix\r\n...<\/pre>\n<p><br \\><\/p>\n<p>Modify following lines in \/etc\/postfix\/main.cf:<\/p>\n<pre>...\r\n#append_dot_mydomain = no\r\nappend_dot_mydomain = yes\r\n...\r\n#relayhost =\r\nrelayhost = [mail.mydomain.com]:587\r\n...<\/pre>\n<p><br \\><\/p>\n<p>Add following lines at the bottom of \/etc\/postfix\/main.cf:<\/p>\n<pre>...\r\n# add mydomain\r\nmydomain = mydomain.local\r\n# enable SASL authentication\r\nsmtp_sasl_auth_enable = yes\r\n# disallow methods that allow anonymous authentication.\r\nsmtp_sasl_security_options = noanonymous\r\n# where to find sasl_passwd\r\nsmtp_sasl_password_maps = hash:\/etc\/postfix\/sasl_passwd\r\n# Enable STARTTLS encryption\r\nsmtp_use_tls = yes\r\n# where to find CA certificates\r\nsmtp_tls_CAfile = \/etc\/ssl\/certs\/ca-certificates.crt<\/pre>\n<p><br \\><\/p>\n<p>Setup access to SMTP server, generate sasl_passwd.db, change owner\/group & permissions, restart postfix and run a test:<\/p>\n<pre>root@vmtest:~# nano \/etc\/postfix\/sasl_passwd\r\n...\r\nroot@vmtest:~# cat \/etc\/postfix\/sasl_passwd\r\n[<smtp.mydomain.com>]:587 <smpt_user>@<smtp_password>\r\nroot@vmtest:~# postmap \/etc\/postfix\/sasl_passwd\r\nroot@vmtest:~# ls -l \/etc\/postfix\/sasl_*\r\n-rw-r--r-- 1 root root    61 Dec 31 16:40 \/etc\/postfix\/sasl_passwd\r\n-rw-r--r-- 1 root root 12288 Dec 31 16:40 \/etc\/postfix\/sasl_passwd.db\r\nroot@vmtest:~# chown root:root \/etc\/postfix\/sasl_*\r\nroot@vmtest:~# chmod 600 \/etc\/postfix\/sasl_*\r\nroot@vmtest:~# ls -l \/etc\/postfix\/sasl_*\r\n-rw------- 1 root root    61 Dec 31 16:40 \/etc\/postfix\/sasl_passwd\r\n-rw------- 1 root root 12288 Dec 31 16:40 \/etc\/postfix\/sasl_passwd.db\r\nroot@vmtest:~# service postfix restart\r\nroot@vmtest:~# echo \"Body of email\" | mail -s \"Subject of email\" me@mydomain.com<\/pre>\n<p><br \\><\/p>\n<p>Logs are stored in \/var\/log\/mail.log<\/p>\n<p>References:<br \/>\n<a href=\"http:\/\/www.postfix.org\/STANDARD_CONFIGURATION_README.html#null_client\">Postfix on a null client<\/a><br \/>\n<a href=\"http:\/\/www.linode.com\/docs\/email\/postfix\/postfix-smtp-debian7\">Configure Postfix to send mail using an external SMTP Server<\/a><br \/>\n<a href=\"http:\/\/discussion.dreamhost.com\/thread-148077.html\">DreamHost Forum - postfix issue<\/a><br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following setup describes a postix setup to send e-mails using an existing SMTP server. It is not designed to receive e-mails. My provider is DreamHost, but setup should be very similar with other hosters. I used a VM with the Ubuntu Server 16.04.1 out of the box installtion (ubuntu-16.04.1-server-amd64). This VM has no real&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/www.geohei.lu\/geoheiWP\/null-client-postfix-setup\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[],"class_list":["post-402","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5mjlH-6u","_links":{"self":[{"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/posts\/402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/comments?post=402"}],"version-history":[{"count":6,"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/posts\/402\/revisions"}],"predecessor-version":[{"id":757,"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/posts\/402\/revisions\/757"}],"wp:attachment":[{"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/media?parent=402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/categories?post=402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.geohei.lu\/geoheiWP\/wp-json\/wp\/v2\/tags?post=402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}