Showing posts with label Dovecot. Show all posts
Showing posts with label Dovecot. Show all posts

Monday, January 14, 2013

Postfix + Dovecot on Centos 6.2 Final Release

Postfix Instalation and Configuration Install postfix package
$ yum install postfix
Edit your main.cf
$ mcedit /etc/postfix/main.cf
and add this basic configuration (change nebula.anekarupatera.lan with your FQDN machine name.
Before editing main.cf we should generate key for ssl/tls certificate, and add the result to main.cf
$ genkey --days 365 nebula.anekarupatera.lan
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
relay_domains =
home_mailbox = Maildir/

inet_interfaces = all
inet_protocols = all

myhostname = nebula.anekarupatera.lan
mydomain = anekarupatera.lan
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.110.0/24, 127.0.0.0/8

unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory
#
# Configuring SSL/TLS in postfix
#
broken_sasl_auth_clients = yes
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
#
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
#
tls_random_source = dev:/dev/urandom
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_tls_key_file = /etc/pki/tls/private/nebula.anekarupatera.lan.key
smtpd_tls_cert_file = /etc/pki/tls/certs/nebula.anekarupatera.lan.cert
Start your postfix service
$ /etc/init.d/postfix start
Dovecot Instalation and Configuration
$ yum install dovecot
Edit your dovecot.conf
$mcedit /etc/dovecot/dovecot.conf
And change the following line from
protocols = imap pop3 lmtp
to
protocols = imap pop3
Start your Dovecot service
$ /etc/init.d/dovecot start

Wednesday, December 14, 2011

Slackware 13.37 + Dovecot 2.0.15 (Configuration)

Get Dovecot 2.0.15 from here (dovecot-2.0.15-i686-1cf.txz) then install it
$ upgradepkg --install-new dovecot-2.0.15-i686-1cf.txz
Then, start for configuration
$ cp -v /usr/doc/dovecot-2.0.15/example-config/* /etc/dovecot/

First create user and group for dovecot
groupadd dovecot
useradd -g dovecot dovecot
useradd -g dovecot dovenull
Here Bellow is my worked configuration : Dovecot.conf
# grep -v "#" /etc/dovecot/dovecot.conf

protocols = imap pop3
listen = *
base_dir = /var/run/dovecot/
login_greeting = Dovecot ready.
dict {}
!include conf.d/*.conf
10-auth.conf
$ grep -v "#" /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = yes
auth_mechanisms = plain login
!include auth-system.conf.ext
10-mail.conf
$ grep -v "#" /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:%h/Maildir
auth_socket_path = /var/run/dovecot/auth-userdb
mail_plugin_dir = /usr/lib/dovecot
mail_plugins = $mail_plugins
10-master.conf
$ grep -v "#" /etc/dovecot/conf.d/10-master.conf

service imap-login {  inet_listener imap {  }  inet_listener imaps {  }}
service pop3-login {  inet_listener pop3 {  }  inet_listener pop3s {  }}
service lmtp {  unix_listener lmtp {  }}
service imap {}
service pop3 {}
service auth {  unix_listener auth-userdb {  }}
service auth-worker {}
service dict {  unix_listener dict {  }}
Dovecot-openssl.cnf
$ grep -v "#" /usr/doc/dovecot-2.0.15/dovecot-openssl.cnf

[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no
[ req_dn ]
C=ID
ST= Indonesia
L=MyCity
O=Dovecot
OU=IMAP server
CN=imap.despro.lan
emailAddress=postmaster@despro.lan
[ cert_type ]
nsCertType = server
$ cd /usr/doc/dovecot-2.0.15/
$ sh mkcert.sh
this action will create /etc/ssl/private/dovecot.pem and /etc/ssl/certs/dovecot.pem have been created. Remember their locations because you have to insert them in 10-ssl.conf
10-ssl.conf
$ grep -v "#" /etc/dovecot/conf.d/10-ssl.conf

ssl_cert =
ssl_key =
20-imap.conf
$ grep -v "#" /etc/dovecot/conf.d/20-imap.conf

protocol imap {mail_plugins = $mail_plugins imap_quota autocreate}
$ grep -v "#" /etc/dovecot/conf.d/20-pop3.conf

protocol pop3 
{mail_plugins = $mail_plugins}
90-plugin.conf
$ grep -v "#" /etc/dovecot/conf.d/90-plugin.conf

plugin 

{    
autocreate = Sent    
autocreate2 = Drafts    
autocreate3 = Junk    
autocreate4 = Trash    
autosubscribe = Sent    
autosubscribe2 = Drafts    
autosubscribe3 = Junk    
autosubscribe4 = Trash
}
90-quota.conf
$ grep -v "#" /etc/dovecot/conf.d/90-quota.conf
plugin {
quota = maildir:User quota
}
auth-system.conf.ext
$ grep -v "#" /etc/dovecot/conf.d/auth-system.conf.ext

passdb {
driver = shadow
}
userdb {
driver = passwd
}
Done

Slackware 13.37 + Dovecot 2.0.15 (POP3 Testing)

This is the way to testing our POP3 installation, every steps should be give correct result.
# telnet localhost 110
# telnet 192.168.110.254 110
# telnet nebula.despro.lan 110
Will given the same results (except IP address and Hostname):
Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.  <-- it means Ctrl + ]+OK Dovecot ready.user fmaster <-- your username+OKpass ******* <-- your password+OK Logged in.quit+OK Logging out.Connection closed by foreign host.
Also check for secure POP connection on port 995
# openssl s_client -connect localhost:995
# openssl s_client -connect 192.168.110.254:995
# openssl s_client -connect nebula.despro.lan:995
Will given same result :
CONNECTED(00000003)
---
---
+OK Dovecot ready.
quit
+OK Logging out
closed
Done

for more advanced testing methode, please take a look these references

ReferensiReferensi 01 Referensi 02

Dovecot Instalation Testing

Check that it's listening
check that Dovecot is listening for connections from locahost
$ telnet localhost 143
Trying ::1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN] Dovecot ready.
^]
check from remote host
$ telnet nebula.anekarupatera.lan 143
Trying 192.168.110.254...
Connected to nebula.anekarupatera.lan.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN] Dovecot ready.
^]
Check that it's allowing logins
check from localhost
$ telnet localhost 143
Trying ::1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN] Dovecot ready.
a login diantokam ********
a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
^]
check from remote host
$ telnet nebula.anekarupatera.lan 143
Trying 192.168.110.254...
Connected to nebula.anekarupatera.lan.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN] Dovecot ready.
a login diantokam ********
a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
^]
check that it find inbox after login, do " b select inbox"
b select inbox
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 6 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1321690865] UIDs valid
* OK [UIDNEXT 906] Predicted next UID
* OK [HIGHESTMODSEQ 1] Highest
b OK [READ-WRITE] Select completed.
Check that it finds other mailboxes after login, do "d lsub "" *"
d lsub "" *
* LSUB () "." "Sent"
* LSUB () "." "Trash"
* LSUB () "." "Drafts"
d OK Lsub completed.
Make a graceful exit
e logout
* BYE Logging out
e OK Logout completed.
Note
^] = Ctrl + ]


Done

Source