Mail Server:MySQL Authentication

 

From ArsLinuxWiki

Jump to: navigation, search

Contents

[edit]

Postifx w/ SASL + Courier IMAP w/ SSL + Maildrop + MySQL + SpamAssassin (Appendix)

[edit]

Acknowledgments

This document is meant to be a continuation of Postifx w/ SASL + Courier IMAP w/ SSL + Maildrop + MySQL + SpamAssassin by Serge Stepanov. These are the troubleshooting steps I had to take to get a functional installation on my RedHat 9 machine. I highly recommend that you run completely through Serge's excellent set of instructions before continuing as I assume that you have completed a configuration like the one he outlines..

[edit]

Troubleshooting

This is the error that I got in /var/log/maillog when I first completed the above HOWTO and tried telnetting to locahost, 25 and sending a test email to test@test.com. I took several steps to resolve it.

§         

 log = /var/log/mysql/mysql.log

under the "[mysqld]" section, created the file /var/log/mysql/mysql.log with uid/gid mysql and restarted MySQL to enable logging.

§         

 insert into postfix_access (source,access,type) values ("*","OK","recipient");

§         

This was the next error I got in /var/log/maillog when trying to send email to my test@test.com user once the "user unknown" error was fixed.

§         

After fixing authmysqlrc to use the correct field for maildir, I got the above error in /var/log/maillog when trying to send to test@test.com.

§         

This was the next error I got in /var/log/maillog when trying to get mail delivered to test@test.com

§         

 email=test@test.com
 uid=520
 gid=520
 homedir=/home/vmail
 maildir=test.com/test/Maildir/

§         

 "insert into postfix_users (email,crypt,name,uid,gid,homedir,maildir) values
("test@test.com",encrypt("password"),520,520,"/home/vmail","test.com/test/Maildir/")"

§         

Once mail was being properly delivered to test@test.com, I set about converting my primary email account over to the MySQL database. This was pretty easy since I could just mimic the test@test.com setup but I was having trouble with the aliases.

§         

Whenever I would try to connect the my mail server, I would get a warning message that the mail server domain didn't match the SSL Certificate domain (which was set to localhost.localdomain). I could still connect and get mail but having to clear this warning message everytime was getting annoying.

§         

 /usr/local/courier/share/imapd.cnf
 /usr/local/courier/share/pop3d.cnf

and were created with the scripts

 /usr/local/courier/share/mkimapdcert
 /usr/local/courier/share/mkpop3dcert

Looking at the the two mkcert scripts reveals that they get their certificate information from the files

 /usr/local/courier/etc/imapd.cnf
 /usr/local/courier/etc/pop3d.cnf

I modified the two .cnf files with the appropriate information for my mail server, deleted the original .pem files and reran the 2 mkcert scripts. Here is the layout of the imapd.cnf file and the fields that need to be changed.

 RANDFILE = /usr/local/courier/share/imapd.rand
 [ req ]
 default_bits = 1024
 encrypt_key = yes
 distinguished_name = req_dn
 x509_extensions = cert_type
 prompt = no
 [ req_dn ]
 C=US (Your 2-character country code)
 ST=KY (Your 2-character locality or state)
 L=Louisville  (Your city name)
 O=example.com Mail Server (Organization name)
 OU=Automatically-generated IMAP SSL key
 CN=example.com (Domain name.  IMPORTANT:  This must be EXACTLY the same as the domain of your mailserver)
 emailAddress=email@example.com
 [ cert_type ]
 nsCertType = server

[edit]

[edit]

Epilogue

After several days of struggling, I finally got a working setup (with a few pieces missing). I also decided I wanted to allow pop3 access as well as imap which meant starting /usr/local/courier/libexec/pop3d-ssl.rc as well as /usr/local/courier/libexec/imapd-ssl.rc.

Next on the list to fix are

 

Retrieved from "Mail Server:MySQL Authentication"

God soul   science fiction   humanity   human life   sense of life   life after death   time machine