1

I've got a mailserver with Postfix, Dovecot, saslauthd and a MySQL storage and auth backend. I can send emails just fine, however receiving emails (from Outlook in this case) fails with messages in /var/log/mysql/mysql.log:

The MySQL log shows these errors:

53 Connect   mail@localhost on mail
53 Connect   Access denied for user 'mail'@'localhost' (using password: YES)
54 Connect   mail@localhost on mail
54 Connect   Access denied for user 'mail'@'localhost' (using password: YES)
55 Connect   mail@localhost on mail
55 Connect   Access denied for user 'mail'@'localhost' (using password: YES)
56 Connect   mail@localhost on mail
56 Connect   Access denied for user 'mail'@'localhost' (using password: YES)

It appears I can't log in to the MySQL server, however, when I do

mysql -u mail -p -h localhost

I can log in fine. The password is known to be correct in both cases.

I have a feeling that this is all caused by Postfix (and subsequently SMTPD I think?) being run in a chroot jail in /var/spool/postfix. I've tried disabling chroot and mounting mysql.sock to a folder in the Postfic chroot, however nothing changes.

I've also tried changing instances of 127.0.0.1 to localhost and vice versa to no avail. Google has been sapped dry by my attempts to find a solution. Maybe I'm searching for the wrong thing.

What do I need to do to allow Postfix to access a MySQL database running on the same server? I want to use MySQL for other things like PHP, so a Postfix-exclusive solution isn't really an option. This has been troubling me for a good 3 days now and I've attempted all the solutions out there.

My /etc/postfix/sasl/smtpd.conf looks like this:

pwcheck_method: auxprop
mech_list: PLAIN LOGIN
log_level: 7
allow_plaintext: true
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: localhost
sql_user: mail
sql_passwd: [hidden]
sql_database: mail
sql_select: select password from mailbox where username='%u@%r' and active = 1

I'm unsure what other files to post, so please comment and I will update accordingly. I'm running Ubuntu Server 12.10 32 bit.

4
  • Does your password have any non alphanumeric characters in it? I've had some strange issues with that, they worked from the command line, but it just wouldn't connect in any other manner.. getting rid of those odd characters solved the issue.
    – NickW
    Feb 28, 2013 at 16:21
  • The password only consists of lowercase, uppercase and numbers, so I can't apply that nice simple fix :(
    – Bojangles
    Feb 28, 2013 at 16:22
  • It's not anything like apparmor is it?
    – NickW
    Feb 28, 2013 at 16:50
  • AppArmor isn't installed, so no
    – Bojangles
    Feb 28, 2013 at 18:08

2 Answers 2

0

I had the same issue username/password correct but in my case, I had this query:

query = select 1 as found from users where email = '%u@%d' and enabled = true LIMIT 1;

The problem was the ending ;.

I just removed and it worked

query = select 1 as found from users where email = '%u@%d' and enabled = true LIMIT 1

The error message could be changed to something more usefully.

0

This was an utterly stupid mistake on my part. It turns out that in the config file /etc/postfix/sasl/smtpd.conf, there was a space after the sql_passwd and other fields, meaning auth failed.

3
  • At least it works :)
    – NickW
    Mar 1, 2013 at 9:28
  • Very true, but now I've got more problems (beyond the scope of my original question)
    – Bojangles
    Mar 1, 2013 at 9:36
  • What sort of issues?
    – NickW
    Mar 1, 2013 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .