-ERR chdir Maildir failed Virtual Users And Domains With Postfix, Courier And MySQL

Discussion in 'Installation/Configuration' started by jacob, Jan 26, 2007.

  1. jacob

    jacob New Member

    I've almost got this working. I can send messages and they show up in /home/vmail/user/domain . I am receiving the following error when I try to pop.

    -ERR chdir Maildir failed
    Connection closed by foreign host.

    maillog:

    Jan 25 23:26:57 gabriel pop3d: Connection, ip=[::ffff:xx.xxx.xxx.xx]
    Jan 25 23:26:57 gabriel authdaemond: received auth request, service=pop3, authtype=login
    Jan 25 23:26:57 gabriel authdaemond: authmysql: trying this module
    Jan 25 23:26:57 gabriel authdaemond: SQL query: SELECT email, password, "", 5000, 5000, "/home/vmail", "", "", "", "" FROM users WHERE email = "[email protected]"
    Jan 25 23:26:57 gabriel authdaemond: password matches successfully
    Jan 25 23:26:57 gabriel authdaemond: authmysql: sysusername=<null>, sysuserid=5000, sysgroupid=5000, homedir=/home/vmail, [email protected], fullname=<null>, maildir=<null>, quota=<null>, options=<null>
    Jan 25 23:26:57 gabriel authdaemond: authmysql: clearpasswd=<null>, passwd=Tw3i7telHCPEw
    Jan 25 23:26:57 gabriel authdaemond: Authenticated: sysusername=<null>, sysuserid=5000, sysgroupid=5000, homedir=/home/vmail, [email protected], fullname=<null>, maildir=<null>, quota=<null>, options=<null>
    Jan 25 23:26:57 gabriel authdaemond: Authenticated: clearpasswd=xxxxxxx, passwd=xyxyxyxyxyxyx
    Jan 25 23:26:57 gabriel pop3d: chdir Maildir: No such file or directory

    Please help !!
     
  2. jacob

    jacob New Member

    Found the problem

    When the doc says
    Then edit /etc/authlib/authmysqlrc. It should look exactly like this (again, make sure to fill in the correct database details):

    It really should be exactly :eek:

    I had a space at the begining of the third line from the bottom


    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
     
    Last edited: Jan 27, 2007
  3. falko

    falko Super Moderator Howtoforge Staff

    Yes, Courier is very finicky about the format.
     
  4. sremac

    sremac New Member

    almost done...

    Hi to everyone,

    POSTFIX is working perfectly, but there is problem:

    I made user in mysql database, and then try to login but there is an error when
    try to get it via telnet:
    (use courrier-pop and courrier-auth):


    Escape character is '^]'.
    +OK Hello there.
    user [email protected]
    +OK Password required.
    pass test
    -ERR chdir virtual.test/test3/ failed
    Connection closed by foreign host.



    and in /var/log/mail.log:


    courierpop3login: chdir virtual.test/test3/: No such file or directory


    Only when I send mail to that user or manually make directory
    in /home/vmail/virtual.test it works!

    Question is: how to automatically add user only via mysql, without need to send e-mail to user or to made directory?

    Does it mean that every mail that is sended, POSTFIX will create new directory at /home/vmail/virtual.test ?

    Thanx!
     
    Last edited: Feb 5, 2007
  5. martinfst

    martinfst Member Moderator

  6. falko

    falko Super Moderator Howtoforge Staff

    That's the normal behaviour. Maildir is created after the first email arrives.
     
  7. sremac

    sremac New Member

    why?

    So,

    it means that senders can send e-mail to my domain, without knowing of my users, and postfix will create directories??

    Is there any option like "user unknown", etc?

    If postfix create directory for every sent mail (for example test1@domain, test2@domain, test3@domain...) it will be a mess in /home/vmail, won`t it?
     
  8. martinfst

    martinfst Member Moderator

    No, postfix default behavioral is to only accept users it knows about. But you need to sent an initial mail to this (existing) user. Or use the maildirmake tool yourself in advance.
     
  9. sremac

    sremac New Member

    I got it..

    Thanx,

    I got it:

    first (if using mysql) user must be created in mysql users table (if not postfix will notice "User unknown" error), and then you can send e-mail to that user or create necessery folders in /home/vmail, but must create as vmail user (because there will be error with permissions, for example if root create /home/vmail/virtual_domain).
     
  10. sremac

    sremac New Member

    but...

    Thought that everything work, but:

    when try to send from one host in network (it`s IP is in $mynetworks in main.cf), there is error with username/password:

    mail.log:


    02:01:29 KanotixBox postfix/smtpd[27738]: > unknown[192.168.2.8]: 334 UGFzc3dvcmQ6
    Feb 9 02:01:29 KanotixBox postfix/smtpd[27738]: < unknown[192.168.2.8]: dGVzdA==
    Feb 9 02:01:29 KanotixBox postfix/smtpd[27738]: xsasl_cyrus_server_next: decoded response: test
    02:01:29 KanotixBox postfix/smtpd[27738]: warning: unknown[192.168.2.8]: SASL LOGIN authentication failed: authentication failure
    Feb 9 02:01:29 KanotixBox postfix/smtpd[27738]: > unknown[192.168.2.8]: 535 5.7.0 Error: authentication failed: authenticationfailure
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: smtp_get: EOF
    02:01:31 KanotixBox postfix/smtpd[27738]: match_hostname: unknown ~? 127.0.0.0/8
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: match_hostaddr: 192.168.2.8 ~? 127.0.0.0/8
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: match_hostname: unknown ~? 192.168.2.0/24
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: match_hostaddr: 192.168.2.8 ~? 192.168.2.0/24
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: lost connection after AUTH from unknown[192.168.2.8]
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: disconnect from unknown[192.168.2.8]
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: master_notify: status 1
    Feb 9 02:01:31 KanotixBox postfix/smtpd[27738]: connection closed



    it seems like there is error with SASL/mySQL or...?

    (username and password are good in mysql and directory is created in /home/vmail.. and smtpd.conf in /etc/postfix/sasl is good, too, also installed SSL sertificate)
     
  11. falko

    falko Super Moderator Howtoforge Staff

    Did you enable "Server requires authentication." in your email client?
     
  12. sremac

    sremac New Member

    yes but...

    Situation is:

    mail clients are setup on right way, and when turned on smtpauth in main.cf server asks user/pass and it works, also when turned off smtpauth on main.cf server don`t ask, but mail can be sent from IP`s that are not in mynetworks in main.cf?

    What option in main.cf tells not to send mails from not-defined networks?


    main.cf:

    ...
    mynetworks = 127.0.0.0/8, 192.168.2.0/24
    smtpd_sasl_auth_enable = yes
    broken_sasl_auth_clients = yes
    smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
    ...

    Thanx!
     
  13. sremac

    sremac New Member

    well

    On Internet are lot of explanation, but still problems

    http://www.postfix.org/SMTPD_ACCESS_README.html

    This option is making problems to me:

    smtpd_client_restrictions = permit_mynetworks, reject

    when I turn it on in main.cf, server responds:

    mail from:<[email protected]>
    250 2.1.0 Ok
    rcpt to:<[email protected]>
    451 4.3.5 Server configuration error


    when trying to aproach from different network.

    So, what options need to be turned in main.cf in order to:

    1. check mynetworks and allow everything from that
    2. if mynetworks don`t pass then to use smtp auth

    ?
     
  14. falko

    falko Super Moderator Howtoforge Staff

    It's all in the tutorial ( http://www.howtoforge.com/virtual_postfix_mysql_quota_courier_p2 ). Please run
    Code:
    postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination'
    /etc/init.d/postfix restart
     
  15. peo

    peo New Member

    Yeah, i checked my file and solved! thanks!!:p
     
  16. AdamBoyle

    AdamBoyle New Member

    Error in 7.04

    Hi,

    This tutorial is brilliant, just what I've been looking for, I am having a problem in connecting to the server via my mail client though.

    I'm getting the error: "sending the password did not succeed. mail server [myhost] responded: chdir [myhost]/[myuser]/ failed."

    I've noticed the file doesnt exist in my /home/vmail directory and have tried sending a few emails through to try and force-create it but the mails keep getting bounced back. Both the user and domain are set up in the mysql database and I'm pretty stumped for ideas from now :confused: :confused:

    Any help would be very much appreciated!
     
  17. falko

    falko Super Moderator Howtoforge Staff

    Are there any errors in your mail log (/var/log/mail.log)?
     
  18. PhilyWisk

    PhilyWisk New Member

    Had the same issue as AdamBoyle, some domains would work some wouldn't, turned out that the domain that wouldn't was named as mydesination setup back on page 2 of the tutorial:

    Code:
    postconf -e 'myhostname = server1.example.com'
    postconf -e 'mydestination = server1.example.com, localhost, localhost.localdomain'
    Just put a www. in front of the domain, don't know if that's a good thing to do or not but it worked. :D
     
    Last edited: Feb 20, 2008
  19. far.east

    far.east New Member

    relay=virtual...

    i think transport must be commented, so in maillog it is known as virtual
     

Share This Page