Mail Disappears into a black hole using postfix, mysql
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Mail sent to my domain apparently disappears into a black hole for 7 days as my mail system delays bouncing it. I'd love to know why.
In this and in all of my further pastebins I have sanitized vital information in order to protect my domain and accounts from abuse. But you should still be able to tell what's going on from the info presented.
Here's one thing I would like to note before we proceed. This is how my virtual_mailbox_base is set in main.cf:
virtual_mailbox_base = /var/spool/mail/virtual
Yet though I have accounts setup in my mysql database, when I cd to that location the directory is completely empty.
Also, another odd thing is that I keep seeing references to user@foo.com. No where in my main.cf is foo.com mentioned so I am at a loss to understand this.
This you might not be able to help with though, because 'foo' is how I obscure my domain in posts to pastebin for security purposes.
Here's my logs (obscured of course using foo and other obfuscations including the nonsensical 666.666.666.666 representing my public IP).
1) I home "myhostname = mail. foo.com" is a typo when you sunbtituted foo, since that space shouldn't be there.
2)According to your logs, you have a virtual domain listed in mydestination, but according to your main.cf, no value for mydestination. Does this mean your logs precede changes to main.cf - in which case they're not too useful.
3) is mysqld running, and if so, where is it's socket? This looks like the major problem.
4) did you try the setup before adding the mysql part, or did you just follow a the guied and cross your fingers? The usual method for setting up postfix (and other things) is to get a basic setup working and add bits at a time.
1) To answer your question, the space in mail. foo.com is actually a slight bug in the perl script I ran to scrub the file of information that would reveal too much detail to the net and possibly expose my config to intruders.
In the actual config file there's no space. It's like "myhostname = mail.foo.com". I'm sorry, I should have corrected that in the pastebin or at least pointed that out.
And yes! My config was working perfectly before my mysqlization. I actually backed up my config files by copying them to main.cf.pre-flurdy should I ever desire to go back and have a working config again.
As to 2) I will correct that and have a go. Thank you for the lucid observation.
3) mysqld is running I can connect to it on the command line and by phpmyadmin. It is running on port 3306, but I don't know how to determine the socket or make it connect via a socket.
4) see above. Yes my postfix was running fine prior to the mysqlization. I do really need to get mysqlization of the backend to postfix running as soon as reasonably possible.
Thanks again for your input.
Quote:
Originally Posted by billymayday
A couple of thoughts
1) I home "myhostname = mail. foo.com" is a typo when you sunbtituted foo, since that space shouldn't be there.
2)According to your logs, you have a virtual domain listed in mydestination, but according to your main.cf, no value for mydestination. Does this mean your logs precede changes to main.cf - in which case they're not too useful.
3) is mysqld running, and if so, where is it's socket? This looks like the major problem.
4) did you try the setup before adding the mysql part, or did you just follow a the guied and cross your fingers? The usual method for setting up postfix (and other things) is to get a basic setup working and add bits at a time.
Thanks. I looked in /etc/mysql/my.cnf and this is what I found regarding the socket:
"socket = /var/run/mysqld/mysqld.sock"
Yet, I still keep getting things like this turn up in my logs:
"Jan 11 08:40:47 mail postfix/cleanup[21753]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
And when I ls -l /var/run/mysqld/mysqld.sock this is what I get:
"srwxrwxrwx 1 mysql mysql 0 2009-01-11 22:02 /var/run/mysqld/mysqld.sock"
Any suggestions on how to proceed with this info?
Thanks
Next time you post logs, etc., can you post them in the thread, relevant parts only and surrounded by code tags please - these links are impossible to follow, and there's topo much irrelevant stuf there.
Your problem seems to revolve around
Code:
2278 Query SELECT 'virtual' FROM domains WHERE domain=' foo.com'
which seems to generate
Code:
Jan 14 09:34:17 mail postfix/virtual[30062]: warning: mysql query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM users WHERE email='amavis@ foo.com'' at line 1
Jan 14 09:34:17 mail postfix/virtual[30062]: warning: table virtual_mailbox_maps: lookup amavis@ foo.com: Success
What is the relevant query that's causing this? I can't immediately identify it from those I've seen.
I looked at the contents of that file and all seems well. I can't figure out why that would be the source of the problem. Here are the contents of the file:
MySQL seems to build the query out of the contents of this file. But I am hard pressed to find an error in the file as I have it here.
And this is the users table in the mail database:
Code:
mysql> DESCRIBE users;
+-----------------+----------------------+------+-----+-------------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+----------------------+------+-----+-------------------------+-------+
| id | varchar(128) | NO | PRI | | |
| name | varchar(128) | NO | | | |
| uid | smallint(5) unsigned | NO | | 5000 | |
| gid | smallint(5) unsigned | NO | | 5000 | |
| home | varchar(255) | NO | | /var/spool/mail/virtual | |
| maildir | varchar(255) | NO | | blah/#this is what it is|
| enabled | tinyint(3) unsigned | NO | | 1 | |
| change_password | tinyint(3) unsigned | NO | | 1 | |
| clear | varchar(128) | NO | | defaultPass | |
| crypt | varchar(128) | NO | | gobbledyGook | |
| quota | varchar(255) | NO | | | |
| procmailrc | varchar(128) | NO | | | |
| spamassassinrc | varchar(128) | NO | | | |
+-----------------+----------------------+------+-----+-------------------------+-------+
13 rows in set (0.00 sec)
Quote:
Originally Posted by billymayday
Next time you post logs, etc., can you post them in the thread, relevant parts only and surrounded by code tags please - these links are impossible to follow, and there's topo much irrelevant stuf there.
Your problem seems to revolve around
Code:
2278 Query SELECT 'virtual' FROM domains WHERE domain=' foo.com'
which seems to generate
Code:
Jan 14 09:34:17 mail postfix/virtual[30062]: warning: mysql query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM users WHERE email='amavis@ foo.com'' at line 1
Jan 14 09:34:17 mail postfix/virtual[30062]: warning: table virtual_mailbox_maps: lookup amavis@ foo.com: Success
What is the relevant query that's causing this? I can't immediately identify it from those I've seen.
Last edited by bluethundr; 01-14-2009 at 06:05 PM.
because I'd expect "select_field=virtual" somewhere
hmmm.. that grep sure produced a lot of output. What is it we're looking for?
Code:
/etc/postfix/main.cf:# this specifies where the virtual mailbox folders will be located
/etc/postfix/main.cf:virtual_mailbox_base = /var/spool/mail/virtual
/etc/postfix/main.cf:virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf
/etc/postfix/main.cf:virtual_uid_maps = mysql:/etc/postfix/mysql_uid.cf
/etc/postfix/main.cf:virtual_gid_maps = mysql:/etc/postfix/mysql_gid.cf
/etc/postfix/main.cf:virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
/etc/postfix/main.cf:virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
/etc/postfix/main.cf:virtual_alias_domains =
/etc/postfix/main.cf:virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
/etc/postfix/main.cf:virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
/etc/postfix/main.cf:virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
/etc/postfix/main.cf:virtual_mailbox_base = /home/vmail
/etc/postfix/main.cf:#virtual_uid_maps = static:5000
/etc/postfix/main.cf:#virtual_gid_maps = static:5000
/etc/postfix/main.cf:# this is how to connect to the domains (all virtual, but the option is there)
/etc/postfix/main.cf:virtual_create_maildirsize = yes
/etc/postfix/main.cf:virtual_mailbox_extended = yes
/etc/postfix/main.cf:virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
/etc/postfix/main.cf:virtual_mailbox_limit_override = yes
/etc/postfix/main.cf:virtual_maildir_limit_message = "The user you are trying to reach is over quota."
/etc/postfix/main.cf:virtual_overquota_bounce = yes
/etc/postfix/main.cf:proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
/etc/postfix/master.cf:virtual unix - n n - - virtual
/etc/postfix/mysql-virtual_domains.cf:select_field = 'virtual'
/etc/postfix/mysql-virtual-mailbox-domains.cf:query = SELECT 1 FROM virtual_domains WHERE name='%s'
Because I believe that mysql query is automagiclly being built from that file,
Code:
/etc/postfix/mysql_mailbox.cf
isn't it?
It looks to me like the query is built from the elements of the file which for easy reference I will repeat here:
but I don't see them being used in your howto. Where did these come from, and what is the conternts of the relevant .cf's?
...hmmm. I didn't notice those. Thanks for pointing them out. I actually did try to follow one other how to before I attempted flurdy's (which is the best I've found so far). I thought I expunged everything from my main.cf that didn't pertain to flurdy's instructions.
Seems I may have missed a couple. These two lines seem like they may be detritus from the previous how-to. Again, thanks for spotting those.
Ahhhhhhhh!!!!!!!! I think we have an anomaly here! Looking at the contents of these files I am beyond _certain_ that they are garbage left over from a previous attempt to put a mysql backend on my mail.
Notice the 'hosts' field is 'localhost' instead of 127.0.0.1 like my other .cf's. But most importantly, if you look at a description of my 'users' table you will notice that there is no 'email' field. Flurdy has that field represented as 'id' in his setup.
So, I am going to take 2 seconds to correct those anomalies. But I'm more interested in commenting those lines out and seeing if my mail setup comes to life!
Wish me luck!
Last edited by bluethundr; 01-15-2009 at 08:35 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.