Hi, I installed a Postfix server with virtual domains according to the excellent tutorial "Virtual Users And Domains With Postfix, Courier And MySQL (Fedora 8)". However, when I receive a mail it is rejected with "Unknown User" message, although the user and the domain exist in the database. Checking the Postifx site i saw that the virtual mailbox domain can't be listed under $mydestination in main.cf (http://www.postfix.org/VIRTUAL_README.html#virtual_mailbox). But in the tutorial the example.com is used both in $mydestination as well as in the virtual domain tables. Since I have a similar configuration, I wonder if this could be the reason for rejecting the mail? Any insight would be much appreciated. Many thanks,
Does it look something like the below? If so thats just postfix/amavis/spamassassin blocking spam. If not then we would need to see some log files to determine what the problem is. Ive used this setup on my server and its working perfectly. Im assuming you have verified all programs are running and ran netstat -tap to see that they are listening on their respective ports. (and of course that the ports are open). HTHT mail postfix/smtpd[9180]: connect from \ 200-127-43-70.cab.prima.net.ar[200.127.43.70] mail postfix/smtpd[9180]: NOQUEUE: reject: RCPT from \ 200-127-43-70.cab.prima.net.ar[200.127.43.70]: 550 5.1.1 \ <[email protected]>: Recipient address rejected: User unknown in virtual mailbox table; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<svnigeg> mail postfix/smtpd[9180]: lost connection after RCPT from 200-127-43-70.cab.prima.net.ar[200.127.43.70]
Thanks for the prompt reply guys. Here is my main.cf, my mysql tables and the error message I receive when an e-mail is sent to me. Please let me know what you think. Thanks My configuration: [root@web ~]# postconf -n alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases broken_sasl_auth_clients = yes command_directory = /usr/sbin config_directory = /etc/postfix content_filter = amavis:[127.0.0.1]:10024 daemon_directory = /usr/libexec/postfix debug_peer_level = 2 html_directory = no inet_interfaces = all mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = web.example.com, localhost, localhost.localdomain myhostname = web.example.com mynetworks = 127.0.0.0/8 newaliases_path = /usr/bin/newaliases.postfix 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 queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.4.5/README_FILES receive_override_options = no_address_mappings sample_directory = /usr/share/doc/postfix-2.4.5/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_tls_cert_file = /etc/postfix/smtpd.cert smtpd_tls_key_file = /etc/postfix/smtpd.key smtpd_use_tls = yes transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf unknown_local_recipient_reject_code = 550 virtual_alias_domains = virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf virtual_gid_maps = static:5000 virtual_mailbox_base = /home/vmail virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf virtual_mailbox_limit_override = yes virtual_maildir_limit_message = "The user you are trying to reach is over quota." virtual_overquota_bounce = yes virtual_uid_maps = static:5000 mysql> use mail Database changed mysql> select * from domains; +-------------+ | domain | +-------------+ | example.com | +-------------+ 1 row in set (0.00 sec) mysql> select * from users; +-------------------+---------------+----------+ | email | password | quota | +-------------------+---------------+----------+ | [email protected] | bnTyKaRCPOvbA | 10485760 | | +-------------------+---------------+----------+ 1 row in set (0.02 sec) Logs of receiving (and rejecting) mail: Jan 22 21:11:31 web postfix/smtpd[2672]: connect from mail.mySender.com[1.2.3.4] Jan 22 21:11:32 web postfix/smtpd[2672]: A20F342A0: client=mail.mySender.com[1.2.3.4] Jan 22 21:11:32 web postfix/cleanup[2681]: A20F342A0: message-id=<[email protected]> Jan 22 21:11:32 web postfix/qmgr[2670]: A20F342A0: from=<[email protected]>, size=11920, nrcpt=1 (queue active) Jan 22 21:11:32 web postfix/smtpd[2672]: disconnect from mail.mySender.com[1.2.3.4] Jan 22 21:11:59 web postfix/smtpd[2688]: connect from unknown[127.0.0.1] Jan 23 05:11:59 web postfix/smtpd[2688]: B50A242A1: client=unknown[127.0.0.1] Jan 22 21:11:59 web postfix/cleanup[2681]: B50A242A1: message-id=<[email protected]> Jan 22 21:11:59 web postfix/qmgr[2670]: B50A242A1: from=<[email protected]>, size=12342, nrcpt=1 (queue active) Jan 23 05:11:59 web postfix/smtpd[2688]: disconnect from unknown[127.0.0.1] Jan 22 21:11:59 web amavis[2175]: (02175-01) Passed CLEAN, [1.2.3.4] [1.2.3.4] <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, mail_id: w4DZ055C-H6e, Hits: -0.499, size: 11920, queued_as: B50A242A1, 26918 ms Jan 22 21:12:00 web postfix/smtp[2682]: A20F342A0: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=28, delays=0.47/0.11/0.14/27, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as B50A242A1) Jan 22 21:12:00 web postfix/qmgr[2670]: A20F342A0: removed Jan 22 21:12:00 web postfix/virtual[2695]: B50A242A1: to=<[email protected]>, relay=virtual, delay=0.48, delays=0.12/0.12/0/0.23, dsn=5.1.1, status=bounced (unknown user: "[email protected]") Jan 22 21:12:00 web postfix/cleanup[2681]: 33F9542A4: message-id=<[email protected]> Jan 22 21:12:00 web postfix/bounce[2696]: B50A242A1: sender non-delivery notification: 33F9542A4 Jan 22 21:12:00 web postfix/qmgr[2670]: B50A242A1: removed Jan 22 21:12:00 web postfix/qmgr[2670]: 33F9542A4: from=<>, size=14144, nrcpt=1 (queue active) Jan 22 21:12:05 web postfix/smtp[2697]: 33F9542A4: to=<[email protected]>, relay=mail.mySender.com[1.2.3.4]:25, delay=5.7, delays=0.06/0.04/5.2/0.34, dsn=2.0.0, status=sent (250 +OK message queued for delivery.) Jan 22 21:12:05 web postfix/qmgr[2670]: 33F9542A4: removed
can you login to mysql using the user/pass you setup for that mysql database? maybe its a communication problem with mysql. If postfix cant login to check the usernames. are you sure the user in the DB is EXACTY correct? could you try recreating it and see if that helps? I can tell by the logs that postfix is receiving the mail correctly, passing it off to amavis correctly, its coming back from amavis correctly (250 OK) but its getting hungup on the user lookup part. which is why i say to check communication from postfix to mysql aka the user/pass of the user you setup for the mail DB, aka mail_admin or something similar.
still stuck Hi, I'm still perplexed by this one . I attached this time some more information including the mysql log (which looks OK to me) and some postfix definition files. My postfix version is postfix-2.4.5-2.fc8. Thanks... sudo cat /etc/postfix/mysql-virtual_transports.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT transport FROM transport WHERE domain='%s' hosts = 127.0.0.1 sudo cat /etc/postfix/mysql-virtual_mailboxes.cf user = mail_admin password = mail_admin_password dbname = mail sudo cat /etc/postfix/mysql-virtual_mailbox_limit_maps.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT quota FROM users WHERE email='%s' hosts = 127.0.0.1 query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s' hosts = 127.0.0.1 sudo cat /etc/postfix/mysql-virtual_forwardings.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT destination FROM forwardings WHERE source='%s' hosts = 127.0.0.1 sudo cat /etc/postfix/mysql-virtual_email2email.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT email FROM users WHERE email='%s' hosts = 127.0.0.1 sudo cat /etc/postfix/mysql-virtual_domains.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT domain AS virtual FROM domains WHERE domain='%s' hosts = 127.0.0.1 mysql tables: ------------- mysql> use mail; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from domains; +-------------+ | domain | +-------------+ | example.com | +-------------+ 1 row in set (0.00 sec) mysql> select * from users; +-------------------+---------------+----------+ | email | password | quota | +-------------------+---------------+----------+ | [email protected] | bnTyKaRCPOvbA | 10485760 | +-------------------+---------------+----------+ 1 row in set (0.02 sec) mysql> select * from forwardings; Empty set (0.00 sec) mysql> select * from transport; Empty set (0.00 sec) my.cnf: ------- [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 bind-address = 127.0.0.1 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid The mysql log: -------------- /usr/libexec/mysqld, Version: 5.0.45-log (Source distribution). started with: Tcp port: 0 Unix socket: /var/lib/mysql/mysql.sock Time Id Command Argument 080124 19:33:23 1 Connect Access denied for user 'UNKNOWN_MYSQL_US'@'localhost' (using password: NO) 080124 19:39:01 2 Connect mail_admin@localhost on mail 2 Query SELECT transport FROM transport WHERE domain='*' 2 Query SELECT transport FROM transport WHERE domain='*' 3 Connect mail_admin@localhost on mail 3 Query SELECT domain AS virtual FROM domains WHERE domain='mySender.com' 2 Query SELECT transport FROM transport WHERE domain='[email protected]' 2 Query SELECT transport FROM transport WHERE domain='mySender.com' 2 Query SELECT transport FROM transport WHERE domain='.com' 3 Query SELECT domain AS virtual FROM domains WHERE domain='example.com' 2 Query SELECT transport FROM transport WHERE domain='[email protected]' 2 Query SELECT transport FROM transport WHERE domain='example.com' 2 Query SELECT transport FROM transport WHERE domain='.us' 4 Connect mail_admin@localhost on mail 4 Query SELECT destination FROM forwardings WHERE source='[email protected]' 5 Connect mail_admin@localhost on mail 5 Query SELECT email FROM users WHERE email='[email protected]' 080124 19:39:09 6 Connect mail_admin@localhost on mail 6 Query set autocommit=1 6 Query SELECT "Y" as local FROM domains WHERE CONCAT("@",domain) IN ('[email protected]','@example.com','@.example.com','@.us','@.') 080124 19:39:54 7 Connect mail_admin@localhost on mail 7 Query SELECT transport FROM transport WHERE domain='*' 7 Query SELECT transport FROM transport WHERE domain='*' 8 Connect mail_admin@localhost on mail 8 Query SELECT domain AS virtual FROM domains WHERE domain='mySender.com' 7 Query SELECT transport FROM transport WHERE domain='[email protected]' 7 Query SELECT transport FROM transport WHERE domain='mySender.com' 7 Query SELECT transport FROM transport WHERE domain='.com' 8 Query SELECT domain AS virtual FROM domains WHERE domain='example.com' 7 Query SELECT transport FROM transport WHERE domain='[email protected]' 7 Query SELECT transport FROM transport WHERE domain='example.com' 7 Query SELECT transport FROM transport WHERE domain='.us' 9 Connect mail_admin@localhost on mail 9 Query SELECT destination FROM forwardings WHERE source='[email protected]' 080124 19:39:55 10 Connect mail_admin@localhost on mail 10 Query SELECT email FROM users WHERE email='[email protected]' 7 Query SELECT transport FROM transport WHERE domain='*' 8 Query SELECT domain AS virtual FROM domains WHERE domain='example.com' 7 Query SELECT transport FROM transport WHERE domain='[email protected]' 7 Query SELECT transport FROM transport WHERE domain='example.com' 7 Query SELECT transport FROM transport WHERE domain='.us' 7 Query SELECT transport FROM transport WHERE domain='*' 9 Query SELECT destination FROM forwardings WHERE source='[email protected]' 10 Query SELECT email FROM users WHERE email='[email protected]' 9 Query SELECT destination FROM forwardings WHERE source='@mySender.com' 10 Query SELECT email FROM users WHERE email='@mySender.com' 080124 19:39:56 8 Query SELECT domain AS virtual FROM domains WHERE domain='mySender.com' 7 Query SELECT transport FROM transport WHERE domain='[email protected]' 7 Query SELECT transport FROM transport WHERE domain='mySender.com' 7 Query SELECT transport FROM transport WHERE domain='.com' 080124 19:40:01 5 Quit 080124 19:40:55 10 Quit Postfix Log: ------------ Jan 24 19:39:00 web postfix/smtpd[2657]: connect from mail.mySender.com[1.2.3.4] Jan 24 19:39:01 web postfix/smtpd[2657]: C3CA8429F: client=mail.mySender.com[1.2.3.4] Jan 24 19:39:02 web postfix/cleanup[2666]: C3CA8429F: message-id=<[email protected]> Jan 24 19:39:02 web postfix/smtpd[2657]: disconnect from mail.mySender.com[1.2.3.4] Jan 24 19:39:02 web postfix/qmgr[1772]: C3CA8429F: from=<[email protected]>, size=11597, nrcpt=1 (queue active) Jan 24 19:39:12 web clamd[1669]: No stats for Database check - forcing reload Jan 24 19:39:12 web clamd[1669]: Reading databases from /var/lib/clamav Jan 24 19:39:47 web clamd[1669]: Database correctly reloaded (364783 signatures) Jan 24 19:39:54 web postfix/smtpd[2675]: connect from unknown[127.0.0.1] Jan 25 03:39:54 web postfix/smtpd[2675]: E2D7442A0: client=unknown[127.0.0.1] Jan 24 19:39:55 web postfix/cleanup[2666]: E2D7442A0: message-id=<[email protected]> Jan 24 19:39:55 web postfix/qmgr[1772]: E2D7442A0: from=<[email protected]>, size=12019, nrcpt=1 (queue active) Jan 25 03:39:55 web postfix/smtpd[2675]: disconnect from unknown[127.0.0.1] Jan 24 19:39:55 web amavis[2165]: (02165-01) Passed CLEAN, [1.2.3.4] [1.2.3.4] <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, mail_id: WTQ22l3CWd9H, Hits: -2.199, size: 11597, queued_as: E2D7442A0, 50864 ms Jan 24 19:39:55 web postfix/smtp[2667]: C3CA8429F: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=54, delays=0.72/0.19/5/48, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as E2D7442A0) Jan 24 19:39:55 web postfix/qmgr[1772]: C3CA8429F: removed Jan 24 19:39:55 web postfix/virtual[2683]: E2D7442A0: to=<[email protected]>, relay=virtual, delay=1.1, delays=0.19/0.56/0/0.29, dsn=5.1.1, status=bounced (unknown user: "[email protected]") Jan 24 19:39:55 web postfix/cleanup[2666]: EB762429F: message-id=<[email protected]> Jan 24 19:39:56 web postfix/qmgr[1772]: EB762429F: from=<>, size=13821, nrcpt=1 (queue active) Jan 24 19:39:56 web postfix/bounce[2684]: E2D7442A0: sender non-delivery notification: EB762429F Jan 24 19:39:56 web postfix/qmgr[1772]: E2D7442A0: removed Jan 24 19:39:56 web postfix/smtp[2685]: EB762429F: to=<[email protected]>, relay=mail.mySender.com[1.2.3.4]:25, delay=0.72, delays=0.17/0.1/0.14/0.31, dsn=2.0.0, status=sent (250 +OK message queued for delivery.) Jan 24 19:39:56 web postfix/qmgr[1772]: EB762429F: removed Jan 24 19:42:22 web postfix/anvil[2660]: statistics: max connection rate 1/60s for (smtp:1.2.3.4) at Jan 24 19:39:00 Jan 24 19:42:22 web postfix/anvil[2660]: statistics: max connection count 1 for (smtp:1.2.3.4) at Jan 24 19:39:00 Jan 24 19:42:22 web postfix/anvil[2660]: statistics: max cache size 1 at Jan 24 19:39:00
Your /etc/postfix/mysql-virtual_mailboxes.cf is wrong. It must look like this: Code: user = mail_admin password = mail_admin_password dbname = mail query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s' hosts = 127.0.0.1
typo Sorry, it was a typo in the post. The content of the file is: cat /etc/postfix/mysql-virtual_mailboxes.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s' hosts = 127.0.0.1 I undersrand that mail will do to the directory /home/vmail/example.com/username/ should I create any files there? Thanks
Is it possible that when building the postfix RPM you didn't change the "%define MYSQL 0" to "%define MYSQL 1" in postfix.spec in step 5? I think that would cause it not to use MySQL all together...
my bad The critical line : virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf was missing from main.cf everything is working now. Sorry for the trouble. Doron