Postfix is a free open source mail transfer agent (MTA), a computer program for the routing and delivery of email. It is intended as a fast, easy-to-administer, and secure alternative to the widely-used Sendmail MTA. Formerly known as VMailer and IBM Secure Mailer, it was originally written by Wietse Venema during a stay at the IBM Thomas J. Watson Research Center, and continues to be actively developed today. Postfix was first released in mid-1999.
Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems, written primarily with security in mind. Developed by Timo Sirainen, Dovecot was first released in July 2002. Dovecot primarily aims to be a lightweight, fast and easy to set up open source mailserver.
Dovecot can work with standard mbox, Maildir, and its own experimental native high-performance dbox formats. [1] It is fully compatible with UW IMAP and Courier IMAP servers' implementation of them, as well as mail clients accessing the mailboxes directly.
Notes: If you are on Windows OS, you should download putty http://www.chiark.greenend.org.uk/~sgtatham/putty/ to SSH.
Now we install Postfix and Dovecot (Dovecot will be our POP3/IMAP server):
yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecot
Next we configure SMTP-AUTH and TLS:
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
postconf -e 'mynetworks = 127.0.0.0/8'
We must edit /usr/lib/sasl2/smtpd.conf so that Postfix allows PLAIN and LOGIN logins. On a 64Bit Centos 5.2 you must edit the file /usr/lib64/sasl2/smtpd.conf instead. It should look like this:
vi /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
Afterwards we create the certificates for TLS:
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
Next we configure Postfix for TLS:
postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'
Then we set the hostname in our Postfix installation (make sure you replace server1.example.com with your own hostname):
postconf -e 'myhostname = drupalab.com'
By default, CentOS' Dovecot daemon provides only IMAP and IMAPs services. Because we also want POP3 and POP3s we must configure Dovecot to do so. We edit /etc/dovecot.conf and enable the line protocols = imap imaps pop3 pop3s:
vi /etc/dovecot.conf
[...]
# Base directory where to store runtime data.
#base_dir = /var/run/dovecot/
# Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
protocols = imap imaps pop3 pop3s
# IP or host address where to listen in for connections. It's not currently
# possible to specify multiple addresses. "*" listens in all IPv4 interfaces.
# "[::]" listens in all IPv6 interfaces, but may also listen in all IPv4
# interfaces depending on the operating system.
[...]
Now start Postfix, saslauthd, and Dovecot:
chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
chkconfig --levels 235 dovecot on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
/etc/init.d/dovecot start
To see if SMTP-AUTH and TLS work properly now run the following command:
telnet localhost 25
After you have established the connection to your Postfix mail server type
ehlo localhost
If you see the lines
250-STARTTLS
and
250-AUTH PLAIN LOGIN
everything is fine.
- bash## telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 server1.example.com ESMTP Postfix
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
- bash#
Type
quit
to return to the system's shell.
Maildir
Dovecot uses Maildir format (not mbox), so if you install ISPConfig on the server, please make sure you enable Maildir under Management -> Server -> Settings -> Email. ISPConfig will then do the necessary configuration.
If you do not want to install ISPConfig, then you must configure Postfix to deliver emails to a user's Maildir (you can also do this if you use ISPConfig - it doesn't hurt ;-)):
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart
To email from Drupal, you have to install "SMTP Authentication Support" module to send email thru SMTP Server.

Comments
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
Nice concise howto... did you happen to do the other part yet?
install "SMTP Authentication Support"
That's the part that's killing me...
:>
Thanks again,
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
This covers smtp auth. Probably one of the most concise accurate tutorials out there.
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
Good tutorial, yet the keys should be generated in /etc/pki/tls/
that's where they belong in CentOS
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
I thank to this article's author. I have seen a video about that in video izle. I support that kind of subject as. I have been always following such as subject as izlesene. Thanks to contributor.
Regards...
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
strange,
1)
i followed this howto and several others (most seem like a direct copy of this one) and when done i'm able to connect with plain pop3 and pop3 over ssl but NOT pop3 over TLS.
if i telnet i DO get the STARTTLS message but if i then tell thunderbird to either: "use TLS if available" or "only use TLS" and then try to fetch mail it just sits there indefinitly trying to connect...
maillog doesn't come up with anything...
imap with TLS does seem to work but i'm not able to get any mail delivered anymore for ..
2)
.. when i send mail to a local user (with just the command 'echo test | mail localuser -s test') the mail disappears.
doesn't show up in /var/spool/mail/localuser and also nowhere to be found in /home/localuser/Maildir/....
any ideas what i'm missing here?
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
Worked great for use with gmail, to remove those annoying "on behalf of" messages with the "Sender" headers enabled. For this, note that you should relay all mail to smtp.gmail.com; otherwise, postfix will try local delivery when send from yourdomain.com to a recipient in yourdomain.com (and it wont work unless you create the users locally OR just route all mail to smtp.gmail.com)
Re: Installing Postfix/Dovecot with SMTP-AUTH and TLS on CentOS
Generic Viagra
Cheap Generic Viagra
Generic Cialis
Propecia
generic cialis