Mysql – Postfix thesql Temporary lookup failure

MySQLpostfix

I'm trying to configure a postfix/courier/mysql/SquirrelMail setup, using this guide, but i get the following error when trying to send an email:

451 4.3.0 <info@mydomain.com>: Temporary lookup failure

/var/log/mail.log entry:

Mar 16 11:37:42 myserver postfix/smtpd[12750]: connect from localhost[127.0.0.1]
Mar 16 11:37:42 myserver postfix/smtpd[12750]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Mar 16 11:37:42 myserver postfix/smtpd[12750]: warning: mysql:/etc/postfix/mysql-virtual_email2email.cf lookup error for "info@mydomain.com"
Mar 16 11:37:42 myserver postfix/smtpd[12750]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 451 4.3.0 <info@mydomain.com>: Temporary lookup failure; from=<info@mydomain.com> to=<info@mydomain.com> proto=ESMTP helo=<webmail.mydomain.com>
Mar 16 11:37:42 myserver postfix/smtpd[12750]: lost connection after RCPT from localhost[127.0.0.1]
Mar 16 11:37:42 myserver postfix/smtpd[12750]: disconnect from localhost[127.0.0.1]

I have rechecked the /etc/postfix/mysql-virtual_email2email.cf file, and it is configured correctly.

user = mypostfixusername
password = mypass
dbname = mail
query = SELECT email FROM users WHERE email='%s'
host = 127.0.0.1

My mysql server is running, i can connect to it using mysql -u mypostfixusername -p, and can run queries. I can also login with SquirrelMail.

Best Answer

The last line in your /etc/postfix/mysql-virtual_email2email.cf should be

hosts = 127.0.0.1

instead of

host = 127.0.0.1

If we specify 127.0.0.1 postfix should try to connect over TCP but your logline says that postfix cant connect to /var/run/mysqld/mysqld.sock and so it didn't recognize the host = 127.0.0.1 line. Hope that helps.