{"id":167,"date":"2013-05-30T17:39:32","date_gmt":"2013-05-30T17:39:32","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=167"},"modified":"2013-05-30T17:39:32","modified_gmt":"2013-05-30T17:39:32","slug":"how-to-install-postfix-on-centos-6","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2013\/05\/30\/how-to-install-postfix-on-centos-6\/","title":{"rendered":"How to Install Postfix on CentOS 6"},"content":{"rendered":"<h3>About Postfix<\/h3>\n<hr \/>\n<p>Postfix is free open source Mail Transfer Agent which works to route and deliver email. Cyrus is a server that helps organize the mail itself.<\/p>\n<h2>Step One \u2014Install Postfix and Cyrus<\/h2>\n<hr \/>\n<p>The first thing to do is install postfix and Cyrus on your virtual private server and the easiest way to do this is through the yum installer.<\/p>\n<pre>sudo yum install Postfix<\/pre>\n<pre>sudo yum install cyrus-sasl\nsudo yum install cyrus-imapd<\/pre>\n<p>Say Yes to the prompt each time it asks. Once all components have downloaded, you will have postfix and cyrus installed.<\/p>\n<h2>Step Two\u2014Configure Postfix<\/h2>\n<hr \/>\n<p>We are going to configure both programs separately.<\/p>\n<p>First, open up the Postfix\u2019s main configuration file.<\/p>\n<pre>sudo vi \/etc\/postfix\/main.cf<\/pre>\n<p>The postfix configuration file is very handy and detailed, providing almost all of the information needed to get the program up and running on your VPS. Unfortunately this also makes for a very long file.<\/p>\n<p>The suggested code below is, in most regards, simply a shortened, and correctly uncommented version of what is in the file already. For a quick set up that will provide you with all of the needed configs to set up postfix, copy and paste the information below over Postfix&#8217;s current configuration. Be careful to correct the domain names under myhostname and mydomain.<\/p>\n<p>Replace the example.com in the myhostname line with a DNS approved domain name. Be sure that the phrase is still mail.yourdomainnamehere<\/p>\n<p>Replace the example.com in the mydomain line with the correct domain name.<\/p>\n<pre>soft_bounce             = no\nqueue_directory         = \/var\/spool\/postfix\ncommand_directory       = \/usr\/sbin\ndaemon_directory        = \/usr\/libexec\/postfix\nmail_owner              = postfix\n\n# The default_privs parameter specifies the default rights used by\n# the local delivery agent for delivery to external file or command.\n# These rights are used in the absence of a recipient user context.\n# DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER.\n#\n#default_privs = nobody\n\nmyhostname              = mail.example.com \nmydomain                = example.com\n\nmydestination           = $myhostname, localhost\nunknown_local_recipient_reject_code = 550\n\nmynetworks_style        = host\nmailbox_transport       = lmtp:unix:\/var\/lib\/imap\/socket\/lmtp\nlocal_destination_recipient_limit       = 300\nlocal_destination_concurrency_limit     = 5\nrecipient_delimiter=+\n\nvirtual_alias_maps      = hash:\/etc\/postfix\/virtual\n\nheader_checks           = regexp:\/etc\/postfix\/header_checks\nmime_header_checks      = pcre:\/etc\/postfix\/body_checks\nsmtpd_banner            = $myhostname\n\ndebug_peer_level        = 2\ndebugger_command =\n         PATH=\/bin:\/usr\/bin:\/usr\/bin:\/usr\/X11R6\/bin\n         xxgdb $daemon_directory\/$process_name $process_id &amp; sleep 5\n\nsendmail_path           = \/usr\/sbin\/sendmail.postfix\nnewaliases_path         = \/usr\/bin\/newaliases.postfix\nmailq_path              = \/usr\/bin\/mailq.postfix\nsetgid_group            = postdrop\nhtml_directory          = no\nmanpage_directory       = \/usr\/share\/man\nsample_directory        = \/usr\/share\/doc\/postfix-2.3.3\/samples\nreadme_directory        = \/usr\/share\/doc\/postfix-2.3.3\/README_FILES\n\nsmtpd_sasl_auth_enable          = yes\nsmtpd_sasl_application_name     = smtpd\nsmtpd_recipient_restrictions    = permit_sasl_authenticated,\n                                  permit_mynetworks,\n                                  reject_unauth_destination,\n                                  reject_invalid_hostname,\n                                  reject_non_fqdn_hostname,\n                                  reject_non_fqdn_sender,\n                                  reject_non_fqdn_recipient,\n                                  reject_unknown_sender_domain,\n                                  reject_unknown_recipient_domain,\n                                  reject_unauth_pipelining,\n                                  reject_rbl_client zen.spamhaus.org,\n                                  reject_rbl_client bl.spamcop.net,\n                                  reject_rbl_client dnsbl.njabl.org,\n                                  reject_rbl_client dnsbl.sorbs.net,\n                                  permit\n\nsmtpd_sasl_security_options     = noanonymous\nsmtpd_sasl_local_domain         = \nbroken_sasl_auth_clients        = yes\n\nsmtpd_helo_required             = yes<\/pre>\n<p>&nbsp;<\/p>\n<h2>Step Three\u2014 Finalize Postfix<\/h2>\n<hr \/>\n<p>After pasting in the proper configs, we are almost finished setting up postfix on our virtual server.<\/p>\n<p>To forestall any errors, we need to execute two more steps<\/p>\n<p>In the config we included virtual aliases with the line, virtual_alias_maps = hash:\/etc\/postfix\/virtual; now we have to set up that database.<\/p>\n<p>Open that file:<\/p>\n<pre>sudo vi \/etc\/postfix\/virtual<\/pre>\n<p>Delete all the text within the file and then add the following single line, substituting an actual username for user, and the correct domain for example.com:<\/p>\n<pre>user@example.com   user\\@example.com<\/pre>\n<p>Save and exit.<\/p>\n<p>Follow up by typing in this into terminal<\/p>\n<pre>postmap \/etc\/postfix\/virtual<\/pre>\n<p>This will turn the virtual file into a lookup table, creating the database required for postfix to work.<\/p>\n<p>Finally conclude by using this command, which will create the new file that postfix expects before sending anything out.<\/p>\n<pre>touch \/etc\/postfix\/body_checks<\/pre>\n<p>Once all that is completed we can finish up by configuring Cyrus.<\/p>\n<h2>Step Four\u2014Configure Cyrus<\/h2>\n<hr \/>\n<p>The first step is to add the smtpd.conf file, which defines the authentication for Postfix\/SASL, to the SASL directory:<\/p>\n<pre>sudo vi \/etc\/sasl2\/smtpd.conf<\/pre>\n<p>Go ahead and copy and paste the following text in:<\/p>\n<pre>pwcheck_method: auxprop\nauxprop_plugin: sasldb\nmech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5<\/pre>\n<p>Save and Exit.<\/p>\n<p>Next, we need to configure the Cyrus file:<\/p>\n<pre>sudo vi \/etc\/imapd.conf<\/pre>\n<p>Delete what is in the file currently, and paste the configurations below into the file, changing the default domain and server name to match your personal domain name.<\/p>\n<pre>virtdomains:\t\tuserid\ndefaultdomain:\t\texample.com\nservername:\t\texample.com\nconfigdirectory:\t\/var\/lib\/imap\npartition-default:\t\/var\/spool\/imap\nadmins:\t\t\tcyrus\nsievedir:\t\t\/var\/lib\/imap\/sieve\nsendmail:\t\t\/usr\/sbin\/sendmail.postfix\nhashimapspool:\t\ttrue\nallowanonymouslogin:\tno\nallowplaintext:\t\tyes\nsasl_pwcheck_method:\tauxprop\nsasl_mech_list:\t\tCRAM-MD5 DIGEST-MD5 PLAIN\ntls_cert_file:\t\t\/etc\/pki\/cyrus-imapd\/cyrus-imapd.pem\ntls_key_file:\t\t\/etc\/pki\/cyrus-imapd\/cyrus-imapd.pem\ntls_ca_file:\t\t\/etc\/pki\/tls\/certs\/ca-bundle.crt\n\nautocreatequota:\t\t-1\ncreateonpost:\t\t\tyes\nautocreateinboxfolders:\t\tspam\nautosubscribeinboxfolders:\tspam<\/pre>\n<p>Save and Exit.<\/p>\n<h2>Step Five\u2014Install a Mail Client<\/h2>\n<hr \/>\n<p>Success! You have installed Postfix and Cyrus on your VPS. However, both of these programs relate to handling email rather than sending it. We can quickly install a method of sending messages from the command line.<\/p>\n<p>There are a variety of clients we can use\u2014here we will connect with MailX<\/p>\n<pre>yum install mailx<\/pre>\n<p>After you agree to the prompt, mailx will finish up installing.<\/p>\n<p>Then, to send emails, type this command into terminal, substituting in the email that you are looking to send your message to.<\/p>\n<pre>mail user@example.org<\/pre>\n<p>Terminal will ask for a subject line. Type one in, then press enter. On the subsequent lines you can type your message. It will only be sent when you press enter, and type in a period.<\/p>\n<p>Your letter will look something like this:<\/p>\n<pre>[root@demoserver ~]# mail user@example.org\nSubject: Hello\nThis is a test message.\nRegards,\n\n.\nEOT<\/pre>\n<p>Congratulations\u2014now you have postfix installed and email running. You are all set to use your virtual private server to send email.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>About Postfix Postfix is free open source Mail Transfer Agent which works to route and deliver email. Cyrus is a server that helps organize the mail itself. Step One \u2014Install Postfix and Cyrus The first thing to do is install postfix and Cyrus on your virtual private server and the easiest way to do this [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[53,60],"tags":[84],"class_list":["post-167","post","type-post","status-publish","format-standard","hentry","category-general","category-linux","tag-how-to-install-postfix-on-centos-6"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}