Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 6.3 x86_64) - Page 3

9 Configure Saslauthd

Edit /etc/sasl2/smtpd.conf. It should look like this:

vi /etc/sasl2/smtpd.conf

pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket

Then turn off Sendmail and start Postfix, saslauthd, and courier-authlib:

chmod 755 /var/spool/authdaemon
chkconfig --levels 235 courier-authlib on
/etc/init.d/courier-authlib start

chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start

 

10 Configure Courier

Now we have to tell Courier that it should authenticate against our MySQL database. First, edit /etc/authlib/authdaemonrc and change the value of authmodulelist so that it reads

vi /etc/authlib/authdaemonrc

[...]
authmodulelist="authmysql"
#authmodulelist="authuserdb authpam authpgsql authldap authmysql authcustom authpipe"
[...]

Then edit /etc/authlib/authmysqlrc. It should look exactly like this (again, make sure to fill in the correct database details):

cp /etc/authlib/authmysqlrc /etc/authlib/authmysqlrc_orig
cat /dev/null > /etc/authlib/authmysqlrc
vi /etc/authlib/authmysqlrc

MYSQL_SERVER localhost
MYSQL_USERNAME mail_admin
MYSQL_PASSWORD mail_admin_password
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
#MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
#MYSQL_NAME_FIELD
MYSQL_QUOTA_FIELD quota

Then restart Courier:

chkconfig --levels 235 courier-imap on
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart

When courier-imap is started for the first time, it automatically creates the certificate files /usr/lib/courier-imap/share/imapd.pem and /usr/lib/courier-imap/share/pop3d.pem from the /usr/lib/courier-imap/etc/imapd.cnf and /usr/lib/courier-imap/etc/pop3d.cnf files. Because the .cnf files contain the line CN=localhost, but our server is named server1.example.com, the certificates might cause problems when you use TLS connections. To solve this, we delete both certificates...

cd /usr/lib/courier-imap/share
rm -f imapd.pem
rm -f pop3d.pem

... and replace the CN=localhost lines in /usr/lib/courier-imap/etc/imapd.cnf and /usr/lib/courier-imap/etc/pop3d.cnf with CN=server1.example.com:

vi /usr/lib/courier-imap/etc/imapd.cnf

[...]
CN=server1.example.com
[...]

vi /usr/lib/courier-imap/etc/pop3d.cnf

[...]
CN=server1.example.com
[...]

Then we recreate both certificates...

./mkimapdcert
./mkpop3dcert

... and restart courier-authlib and courier-imap:

/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart

By running

telnet localhost pop3

you can see if your POP3 server is working correctly. It should give back +OK Hello there. (type quit to get back to the Linux shell):

[root@server1 share]# telnet localhost pop3
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Hello there.
<-- quit
+OK Better luck next time.
Connection closed by foreign host.
[root@server1 share]#

 

11 Modify /etc/aliases

Now we should open /etc/aliases. Make sure that postmaster points to root and root to your own username or your email address, e.g. like this:

vi /etc/aliases

[...]
postmaster: root
root: postmaster@yourdomain.tld
[...]

or like this (if administrator is your own username):

[...]
postmaster: root
root: administrator
[...]

Whenever you modify /etc/aliases, you must run

newaliases

afterwards and restart Postfix:

/etc/init.d/postfix restart

Share this page:

12 Comment(s)

Add comment

Comments

From: pepo at: 2013-04-05 21:26:12

I had some problems to send email though the server. Checking the maillogs I found these errors:

Apr  5 22:46:06 pepomail postfix/smtpd[23884]: connect from ******.nl[80.100.0.0]
Apr  5 22:46:06 pepomail postfix/smtpd[23884]: warning: SASL authentication failure: cannot connect to Courier authdaemond: No such file or directory
Apr  5 22:46:06 pepomail postfix/smtpd[23884]: warning: SASL authentication failure: Password verification failed
Apr  5 22:46:06 pepomail postfix/smtpd[23884]: warning: *****.nl[80.100.0.0]: SASL PLAIN authentication failed: generic failure

After a little Googleling I found that the jail of postfix causes this problem. You can solve this by adding a simlink to the authdaemon socket file inside of the chroot:

cd /var/spool/postfix
ln /var/spool/authdaemon/socket courier-authdaemon-socket

Then change the authdaemond_path in your smtpd.conf to just ‘courier-authdaemon-socket’. Restart postfix and it should work

Check http://www.brandonchecketts.com/archives/configuring-postfix-sasl-to-authenticate-against-courier-authlib for details.

Happy mailing!

pepo

From: Roneil Balbarino at: 2013-04-23 20:49:51

Hi,  

What if my mailbox directory looks like in below table.?

Another thing is I am using vquota in main.cf where I set the quotas per mail addresses.

 virtual_mailbox_limit_maps = hash:/etc/postfix/vquota

What should the script looks like? I was having trouble making the script works. Would really appreciate if someone could help me. Thanks! 

#            |
#            |
#        home/vmail
#            |
#            |
#    -----------------
#    |       |       |
#    |       |       |
# user1/   user2/  user3/
#                    |
#                    |
#                maildirsize
#

From: Lokendra at: 2013-07-30 10:18:32

Hi there,

I have successfully integrated Vadmin plugin in to squirrelmail.

Using vadmin I am able to create users, but when I try to login using new user credentials, I get "ERROR: Connection dropped by IMAP server."

and when I send welcome message using mailx command and try to login again, it logs-in successfully.

 

My question is can we send welcome mail to new users using vadmin plugin or some other way.

 

Please reply back as soon as possible..

 

Also there is no sql table structure defined required by vadmin , i have to improvise and created tables and columns by looking its queries.

Can you please help me locate table structure required by vadmin.

 

Thank you in advance..!

 

From: ggajic at: 2013-11-23 16:30:22

Hi, package cyrus-sasl-plain is missing. When  I tried:

]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.


Connection closed by foreign host.
this is what I got in /var/log/maillog:

Nov 23 17:20:40 mail postfix/smtpd[13580]: connect from localhost[::1]
Nov 23 17:20:40 mail postfix/smtpd[13580]: warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms
Nov 23 17:20:40 mail postfix/smtpd[13580]: fatal: no SASL authentication mechanisms
Nov 23 17:20:41 mail postfix/master[8319]: warning: process /usr/libexec/postfix/smtpd pid 13580 exit status 1
Nov 23 17:20:41 mail postfix/master[8319]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

  yum install cyrus-sasl-plain

solves problem

From: Samuel Vera at: 2013-05-29 22:03:36

error 

los log del mailog

chdir example.com/sales/: No such file or directory

May 29 11:49:47 server1 imapd: sales@example.com: No such file or directory

ERROR: Connection dropped by IMAP server

 

 

pliss help

From: at: 2013-06-01 20:24:31

error squirrelmail Submitted by Samuel Vera (not registered) on Wed, 2013-05-29 23:03. error los log del mailog chdir example.com/sales/: No such file or directory May 29 11:49:47 server1 imapd: sales@example.com: No such file or directory ERROR: Connection dropped by IMAP server pliss help

From: Anonymous at: 2013-06-06 04:20:57

hi, i have the same issue with your email server Connection drop by IMAP server, how's your email server, did you solve the problem? how can i fix it? thanks

From: deny yulianto at: 2013-09-23 18:43:23

If you had an error like ERROR: Connection dropped by IMAP server when you log into you squirrelmail and you check on your email log you found something like this>>>> chdir example.com/sales/: No such file or directory server1 imapd: sales@example.com: No such file or directory. DONT DO THIS >>> INSERT INTO `transport` (`domain`, `transport`) VALUES ('example.com', 'smtp:mail.example.com'); If you do that, your email will loopback by sending your email into your linux system user that used mailx for send the message. Your mail will be delivered to /var/spool/mail/your_user_name. try to vi /var/spool/mail/your_user_name to check your mail that was looped back. The solution is DROP your 'transport' table values on your mail database. Then your mail server should be okay.

From: Anonymous at: 2013-12-08 05:12:47

hi all, I followed all the tutorial regarding this postfix mail server configuration. Everything was going fine. But at last when i logged into the squirrelmail page, previously there was error like "Error: Connection Drop by IMAP server" so, i drop the 'transport' table values. But now, when i logged into the squirrelmail, a blank page appear with no data. Please guys help me. I cannot find the solution.

From: Anonymous at: 2013-12-08 05:29:37

hi all, I have following this tutorial for mail server configuration. Everything was working fine.But finally when i logged in to the squirrel mail, previously there was error like "Error: Connection Drop by IMAP server" and i drop the 'transport' table values and again try to logged in to the squirrel, the IMAP error message is gone but there is no data on squirrel mail page. Guys please help.

the log message when i logged into the squirrel mail home page is following:

tail -f /var/log/maillog

Dec 5 11:23:26 mail imapd: Connection, ip=[::ffff:127.0.0.1] Dec 5 11:23:26 mail imapd: LOGIN, user=sic@pokhara.com, ip=[::ffff:127.0.0.1], port=[33857], protocol=IMAP

Dec 5 11:23:26 mail imapd: LOGOUT, user=sic@pokhara.com, ip=[::ffff:127.0.0.1], headers=0, body=0, rcvd=30, sent=238, time=0 Dec 5 11:23:46 mail clamd[1839]: SelfCheck: Database status OK.

From: Hadi at: 2014-11-27 16:02:48


Any one will follow this tutorial will have a problem: Connection dropped by IMAP

 The Solution ( if you have the user : admin @ example.com )

create the directory example.com in "/home/vmail"

 then create the user admin mailbox:

 maildirmake  /home/vmail/example.com/admin

 chown vmail.vmail -R /home/vmail/example.com

 

From: admin at: 2014-11-28 07:21:59

The Mailbox gets xreated automatically by postfix when the first email arrives. Thats why the guide contains instructions to send a mail to the Mailbox first before you use it.