Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > HOWTO-Related Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 7th January 2008, 22:18
doronkeller doronkeller is offline
Junior Member
 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rejected e-mail (unknown user) w/Postfix

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_READM...rtual_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,
Reply With Quote
Sponsored Links
  #2  
Old 8th January 2008, 18:39
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,744 Times in 2,577 Posts
Default

I'm using server1.example.com in the mydestination line, not example.com. That's a difference.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 12th January 2008, 16:07
c0mputernick c0mputernick is offline
Junior Member
 
Join Date: Jan 2008
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Default

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 \ <9070707@mydomain.com>: Recipient address rejected: User unknown in virtual mailbox table; from=<gamers-unite.net@reefreef.com> to=<9070707@mydomain.com> 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]
Reply With Quote
  #4  
Old 23rd January 2008, 06:45
doronkeller doronkeller is offline
Junior Member
 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 |
+-------------------+---------------+----------+
| doron@example.com | 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=<F7A41358F8C60649845896DA64953A16022AECF3@mySen der14.mySender.com>
Jan 22 21:11:32 web postfix/qmgr[2670]: A20F342A0: from=<dkeller@mySender.com>, 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=<F7A41358F8C60649845896DA64953A16022AECF3@mySen der14.mySender.com>
Jan 22 21:11:59 web postfix/qmgr[2670]: B50A242A1: from=<dkeller@mySender.com>, 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] <dkeller@mySender.com> -> <doron@example.com>, Message-ID: <F7A41358F8C60649845896DA64953A16022AECF3@mySender 14.mySender.com>, 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=<doron@example.com>, 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=<doron@example.com>, relay=virtual, delay=0.48, delays=0.12/0.12/0/0.23, dsn=5.1.1, status=bounced (unknown user: "doron@example.com")
Jan 22 21:12:00 web postfix/cleanup[2681]: 33F9542A4: message-id=<20080123051200.33F9542A4@web.example.com>
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=<dkeller@mySender.com>, 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
Reply With Quote
  #5  
Old 23rd January 2008, 15:25
c0mputernick c0mputernick is offline
Junior Member
 
Join Date: Jan 2008
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.
Reply With Quote
  #6  
Old 25th January 2008, 05:13
doronkeller doronkeller is offline
Junior Member
 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy 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 |
+-------------------+---------------+----------+
| doron@example.com | 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='dkeller@mySender.com'
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='doron@example.com'
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='doron@example.com'
5 Connect mail_admin@localhost on mail
5 Query SELECT email FROM users WHERE email='doron@example.com'
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 ('doron@example.com','@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='dkeller@mySender.com'
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='doron@example.com'
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='doron@example.com'
080124 19:39:55 10 Connect mail_admin@localhost on mail
10 Query SELECT email FROM users WHERE email='doron@example.com'
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='doron@example.com'
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='dkeller@mySender.com'
10 Query SELECT email FROM users WHERE email='dkeller@mySender.com'
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='dkeller@mySender.com'
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=<F7A41358F8C60649845896DA64953A16916822@mySende r14.mySender.com>
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=<dkeller@mySender.com>, 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=<F7A41358F8C60649845896DA64953A16916822@mySende r14.mySender.com>
Jan 24 19:39:55 web postfix/qmgr[1772]: E2D7442A0: from=<dkeller@mySender.com>, 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] <dkeller@mySender.com> -> <doron@example.com>, Message-ID: <F7A41358F8C60649845896DA64953A16916822@mySender14 .mySender.com>, mail_id: WTQ22l3CWd9H, Hits: -2.199, size: 11597, queued_as: E2D7442A0, 50864 ms
Jan 24 19:39:55 web postfix/smtp[2667]: C3CA8429F: to=<doron@example.com>, 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=<doron@example.com>, relay=virtual, delay=1.1, delays=0.19/0.56/0/0.29, dsn=5.1.1, status=bounced (unknown user: "doron@example.com")
Jan 24 19:39:55 web postfix/cleanup[2666]: EB762429F: message-id=<20080125033955.EB762429F@web.example.com>
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=<dkeller@mySender.com>, 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
Reply With Quote
  #7  
Old 26th January 2008, 18:33
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,744 Times in 2,577 Posts
Default

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
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #8  
Old 27th January 2008, 07:18
doronkeller doronkeller is offline
Junior Member
 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #9  
Old 27th January 2008, 09:42
iyeat iyeat is offline
Member
 
Join Date: Dec 2007
Posts: 43
Thanks: 4
Thanked 1 Time in 1 Post
Default

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...
Reply With Quote
  #10  
Old 27th January 2008, 20:09
doronkeller doronkeller is offline
Junior Member
 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default 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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 09:29
Postfix problem: lost connection after CONNECT from unknown fernando_torrez Server Operation 5 30th November 2007 14:17
Apache2 Freezes celtic Server Operation 31 28th May 2007 17:18
Core 4: Error Messages on Fresh Install re CTX/SSL jjw Installation/Configuration 30 6th September 2006 12:16
configuring IPTABLES firewall adityavpratap HOWTO-Related Questions 9 27th May 2006 21:42


All times are GMT +2. The time now is 06:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.