PDA

View Full Version : Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAs


ruskicar
6th January 2006, 10:11
Hy everyone.

I have a question. If i don't want to use quota in postfix (becuse only i use my server and i don't need no quota), can i simply skip the point that describes how to apply quota patch to postfix and quota exceedance notifications?

Thankyou, Bye,
Drejc

falko
6th January 2006, 11:09
I think so. You might also have to modify the Postfix configuration files.
On the other hand, it doesn't really hurt if your Postfix supports quota. ;)

ruskicar
6th January 2006, 22:18
Hy.

Well, I set up everything that is described in Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAssassin, ClamAV) howto.
And everything works great, except one thing:
I can't connect to my mailserver with for example mozilla thunderbird mail client from any another computer. It says that password is wrong, and even courierpop3login says:
Jan 6 22:10:07 lintvern courierpop3login: LOGIN FAILED, ip=[::ffff:193.77.177.132]

But I have the right password, I am pretty sure about that.

Is there anything else I should enable?

Regards, Drejc

ruskicar
6th January 2006, 22:44
Even if I start:
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.com.
Escape character is '^]'.
+OK Hello there.
user ruskicar
+OK Password required.
pass ######

It says Login Failed
But I can check mail with mutt and there is no problem.

What if I install Qpopper?
Will everything work all-right then?

Regards, RuskiCar

falko
7th January 2006, 00:32
Even if I start:
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.com.
Escape character is '^]'.
+OK Hello there.
user ruskicar
+OK Password required.
pass ######

It says Login Failed
But I can check mail with mutt and there is no problem.
Please check the format of /etc/courier/authmysqlrc (spaces, tabs, etc.). Courier is very finicky about the format.

What if I install Qpopper?
Will everything work all-right then?

Don't install Qpopper! :eek: It won't work!

ruskicar
7th January 2006, 11:02
Hy.

I have done the check of authmysqlrc, and everything is ok (no spaces or brackets). I've restarted all /etc/init.d/courier* and postfix, but still pop3 login doesn't work.

Is it ok, that MYSQL_SERVER in localhost, or should it be sth. else? What about ownership of authmysqlrc and authdaemonrc? I have them set to daemon:daemon. Is this ok?

Is there anything else to check or replace?

Hope to hearing from you soon,
RuskiCar

falko
7th January 2006, 11:50
Is there anything else than
Jan 6 22:10:07 lintvern courierpop3login: LOGIN FAILED, ip=[::ffff:193.77.177.132]

in the mail log?
Are you sure you're using the correct username (must be an email address) and password?
Did you follow the tutorial to the letter? Maybe you made a typo somewhere?

ruskicar
7th January 2006, 11:56
OHMYGOD :)

Sorry...I've completely forgot to use login username as username@hostname.com :)

But now my syslog says:
Jan 7 11:54:57 lintvern courierpop3login: Connection, ip=[::ffff:193.77.17.199]
Jan 7 11:54:57 lintvern courierpop3login: chdir "home/vmail": No such file or directory

Anyway, I have another question. What if someone sends e-mail to root or some other users from /etc/aliases. Should I put all users from /etc/aliases to forwardings table?

Bye

falko
7th January 2006, 12:45
OHMYGOD :)

Sorry...I've completely forgot to use login username as username@hostname.com :)

But now my syslog says:
Jan 7 11:54:57 lintvern courierpop3login: Connection, ip=[::ffff:193.77.17.199]
Jan 7 11:54:57 lintvern courierpop3login: chdir "home/vmail": No such file or directory
I guess you didn't follow the tutorial to the letter because on http://www.howtoforge.com/virtual_postfix_mysql_quota_courier_p2 it says:

groupadd -g 5000 vmail
useradd -g vmail -u 5000 vmail -d /home/vmail -m which means /home/vmail is created if it doesn't exist.

Anyway, I have another question. What if someone sends e-mail to root or some other users from /etc/aliases. Should I put all users from /etc/aliases to forwardings table?

Bye
No, don't put real system users into the database!
If someone sends mails to users from /etc/aliases, these mails will get delivered as described in /etc/aliases. Postfix can distinguish between system users and virtual users.

ruskicar
7th January 2006, 12:48
I've even tried to send e-mail from telnet:
telnet localhost 25
ehlo localhost
250-lintvern.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
mail from:<ruskicar@lintvern.net>
250 Ok
rcpt to:<jammz@lintvern.net>
250 Ok
data
354 End data with <CR><LF>.<CR><LF>
Testing blabla.
.
250 Ok: queued as 5BC8A2EB7D
quit
221 Bye

And /var/log/mail.log says:

Jan 7 12:37:32 lintvern postfix/smtpd[12139]: connect from localhost.localdomain[127.0.0.1]

Jan 7 12:38:41 lintvern postfix/smtpd[12139]: BA2582EB71: client=localhost.localdomain[127.0.0.1]

Jan 7 12:39:01 lintvern postfix/cleanup[12146]: BA2582EB71: message-id=<20060107114457.5BC8A2EB7D@lintvern.net>

Jan 7 12:39:01 lintvern postfix/qmgr[11946]: BA2582EB71: from=<ruskicar@lintvern.net>, size=367, nrcpt=1 (queue active)

Jan 7 12:39:02 lintvern amavis[2552]: (02552-03) lookup_sql: 2006, MySQL server has gone away

Jan 7 12:39:02 lintvern amavis[2552]: (02552-03) NOTICE: Disconnected from SQL server

Jan 7 12:39:02 lintvern amavis[2552]: (02552-03) TROUBLE in check_mail: creating_partsdir FAILED: DBD::mysql::st execute failed: MySQL server has gone away at (eval 38) line 238, <GEN17> line 8481.

Jan 7 12:39:02 lintvern amavis[2552]: (02552-03) PRESERVING EVIDENCE in /var/lib/amavis/amavis-20060106T215628-02552

Jan 7 12:39:02 lintvern postfix/smtp[12147]: BA2582EB71: to=<jammz@lintvern.net>, relay=127.0.0.1[127.0.0.1], delay=51,
status=deferred (host 127.0.0.1[127.0.0.1] said: 451 4.5.0 Error in processing, id=02552-03, creating_partsdir FAILED: DBD::mysql::st execute failed: MySQL server has gone away at (eval 38) line 238, <GEN17> line 8481. (in reply to end of DATA command))

Jan 7 12:39:06 lintvern postfix/smtpd[12139]: disconnect from localhost.localdomain[127.0.0.1]

Hope this will help in any kind of way.
Regards,
Drejc

ruskicar
7th January 2006, 12:55
I followed the instructions and there is /home/vmail directory on my server! I don't know why courier doesn't find it.

No, don't put real system users into the database!
If someone sends mails to users from /etc/aliases, these mails will get delivered as described in /etc/aliases. Postfix can distinguish between system users and virtual users.
But there are some real system users on my server, for example myself (ruskicar = postmaster). And postfix says there is no user ruskicar in virtual table...so I don't get any mail in mutt (as i was used to before).

Jan 7 12:56:41 lintvern postfix/smtpd[12211]: NOQUEUE: reject: RCPT from mta2.siol.net[193.189.160.133]: 550 <ruskicar@lintvern.net>: Recipient address rejected: User unknown in virtual mailbox table; from=<ruskicar@siol.net> to=<ruskicar@lintvern.net> proto=ESMTP helo=<mta2.siol.net>

falko
7th January 2006, 15:27
Does /etc/courier/authmysqlrc look like this?

MYSQL_SERVER localhost
MYSQL_USERNAME mail_admin
MYSQL_PASSWORD mail_admin_password
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
#MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
#MYSQL_NAME_FIELD
MYSQL_QUOTA_FIELD quota

Please post the output of ls -la /home

Also post the output of netstat -tap

ruskicar
7th January 2006, 15:48
Yes, /etc/courier/authmysqlrc looks like that (only that I have some lines that are originally in /etc/courier/authmysqlrc and are all commented)

ls -la /home:

ruskicar@lintvern:/$ ls -la /home
total 72
drwxrwsr-x 7 root staff 4096 2006-01-06 21:54 ./
drwxr-xr-x 21 root root 4096 2006-01-06 19:26 ../
drwxr-xr-x 2 ftp nogroup 4096 2006-01-06 21:20 ftp/
drwxr-xr-x 2 jammz jammz 4096 2006-01-06 21:54 jammz/
drwxr-xr-x 2 root root 49152 2006-01-06 19:23 lost+found/
drwxr-xr-x 3 ruskicar ruskicar 4096 2006-01-06 21:51 ruskicar/
drwxr-xr-x 3 vmail vmail 4096 2006-01-06 23:57 vmail/


netstat -tap:

lintvern:~# netstat -tap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 localhost.localdo:10024 *:* LISTEN 2089/amavisd (maste
tcp 0 0 localhost.localdo:10025 *:* LISTEN 12462/master
tcp 0 0 localhost.localdo:mysql *:* LISTEN 13032/mysqld
tcp 0 0 lintvern.ne:netbios-ssn *:* LISTEN 5789/smbd
tcp 0 0 *:ftp *:* LISTEN 3112/proftpd: (acce
tcp 0 0 *:smtp *:* LISTEN 12462/master
tcp 0 0 lintvern.n:microsoft-ds *:* LISTEN 5789/smbd
tcp 1 0 localhost.localdo:33011 localhost.localdo:mysql CLOSE_WAIT 2552/amavisd (child
tcp 1 0 localhost.localdo:33023 localhost.localdo:mysql CLOSE_WAIT 2553/amavisd (child
tcp 1 0 localhost.localdo:33056 localhost.localdo:mysql CLOSE_WAIT 2551/amavisd (child
tcp 1 0 localhost.localdo:33041 localhost.localdo:mysql CLOSE_WAIT 2554/amavisd (child
tcp 0 0 lintvern.ne:netbios-ssn pc.lintvern.net:1031 ESTABLISHED11433/smbd
tcp6 0 0 *:imaps *:* LISTEN 2203/couriertcpd
tcp6 0 0 *:pop3s *:* LISTEN 2224/couriertcpd
tcp6 0 0 *:pop3 *:* LISTEN 11838/couriertcpd
tcp6 0 0 *:imap2 *:* LISTEN 11823/couriertcpd
tcp6 0 0 *:www *:* LISTEN 2999/apache2
tcp6 0 0 *:ssh *:* LISTEN 2442/sshd
tcp6 0 0 *:smtp *:* LISTEN 12462/master
tcp6 0 0 *:https *:* LISTEN 2999/apache2
tcp6 104 0 ::ffff:192.168.1.1:ssh ::ffff:192.168.1.2:2317 ESTABLISHED12325/sshd: ruskica


Regards, RuskiCar

till
7th January 2006, 19:02
Please make sure that you dont have any whitespaces behind the values in /etc/courier/authmysqlrc and the other courier files. Courier does not strip whitespaces that where behind any value.

ruskicar
7th January 2006, 19:26
Till, I have already checked this twice :).

Any other proposals?

Bye,RuskiCar

falko
7th January 2006, 19:56
Yes, /etc/courier/authmysqlrc looks like that (only that I have some lines that are originally in /etc/courier/authmysqlrc and are all commented)
Please try to use the file from the tutorial, without any other lines/comments. Maybe that makes a difference.

What's in /etc/hosts?

ruskicar
7th January 2006, 20:08
Hy.

Great! I've really tried to use the same file /etc/courier/authmysqlrc from tutorials, and now user jammz (which is in virtual table) can log in the system. How strange... Thanks.

But I still have the problem with real system users. If I want to send mail to ruskicar, I still get the message:

Jan 7 12:56:41 lintvern postfix/smtpd[12211]: NOQUEUE: reject: RCPT from mta2.siol.net[193.189.160.133]: 550 <ruskicar@lintvern.net>: Recipient address rejected: User unknown in virtual mailbox table; from=<ruskicar@siol.net> to=<ruskicar@lintvern.net> proto=ESMTP helo=<mta2.siol.net>

Here is my /etc/hosts:

127.0.0.1 localhost.localdomain localhost lintvern
192.168.1.1 lintvern.net lintvern
192.168.1.20 pc.lintvern.net pc
192.168.1.21 notebook.lintvern.net notebook

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


Regards, Drejc

falko
7th January 2006, 20:14
But I still have the problem with real system users. If I want to send mail to ruskicar, I still get the message:

Jan 7 12:56:41 lintvern postfix/smtpd[12211]: NOQUEUE: reject: RCPT from mta2.siol.net[193.189.160.133]: 550 <ruskicar@lintvern.net>: Recipient address rejected: User unknown in virtual mailbox table; from=<ruskicar@siol.net> to=<ruskicar@lintvern.net> proto=ESMTP helo=<mta2.siol.net>

Is lintvern.net a domain that you manage in the Postfix MySQL database? Then you have to create a new virtual user for ruskicar@lintvern.net to be able to accept emails for that address.

ruskicar
7th January 2006, 20:20
Yes I manage lintvern.net as a virtual domain in mysql postfix database.
But I don't want to add my email to mysql database, because I want that postfix recognizes me as a real system user. If I add ruskicar@lintvern.net to mysql, than I should put all /etc/aliases to mysql, shouldn't I?

I don't know...is there any other possibility?

Bye, RuskiCar

ruskicar
7th January 2006, 20:24
Just something: What if I put some other subdomain in mysql domain list (for example email.lintvern.net). Will then mail for ruskicar@lintvern.net work normal? And if I then add user jammz with /bin/false shell, will he be able to connect my server via pop3?
Because I can make that, if it's about to work ofcourse :).

Bye

ruskicar
7th January 2006, 22:09
Well...I have tried this (to replace domain lintvern.net in mysql with email.lintvern.net), and now when I send e-mail to ruskicar@lintvern.net i get this message:

Jan 7 22:01:05 lintvern postfix/smtpd[14725]: connect from mta2.siol.net[193.189.160.133]

Jan 7 22:01:06 lintvern postfix/smtpd[14725]: NOQUEUE: reject: RCPT from mta2.siol.net[193.189.160.133]: 554 <ruskicar@lintvern.net>: Relay access denied; from=<ruskicar@siol.net> to=<ruskicar@lintvern.net> proto=ESMTP helo=<mta2.siol.net>

Jan 7 22:01:06 lintvern postfix/smtpd[14725]: disconnect from mta2.siol.net[193.189.160.133]

Relay access denied...
Any suggestions?

Regards,Drejc

falko
7th January 2006, 23:53
Please put lintvern.net into the mydestination line in /etc/postfix/main.cf (e.g. mydestination = server1.example.com, localhost, localhost.localdomain, lintvern.net) and restart Postfix.

ruskicar
9th January 2006, 22:40
Sorry for not being on forum for such a long time :).

Well...I have repaired this whole problem somehow else, so everything works now.

But now I have some other question :):
I would like postfix to automatically delete emails which have ***SPAM*** in it's subject. Can this be done by postfix or should I use some other filtering method?

Regards,Drejc

falko
9th January 2006, 23:22
But now I have some other question :):
I would like postfix to automatically delete emails which have ***SPAM*** in it's subject. Can this be done by postfix or should I use some other filtering method?

Regards,Drejc
You can do it with amavisd_new (which is installed on http://www.howtoforge.com/virtual_postfix_mysql_quota_courier_p3 ). Have a look at the amavisd_new documentation.
Something like $final_spam_destiny = D_REJECT; should work.

till
10th January 2006, 11:10
It loks like there where problems with your amavis setup. Please check the mysql username, password, database name and database host in the amavis configuration. You can also check the mysql logs for errors.

hafizh_nix
19th July 2007, 20:58
Hii all,

I have problem with my postfix+fetchmail. How to fetchmail can recognize postfix mail_base '/home/vmail'?

Thanks b 4 :D

falko
20th July 2007, 16:28
Do you use virtual email users?