Postfix with Virtual Users And Domains

Discussion in 'Server Operation' started by AhmadElGendi, Dec 21, 2011.

  1. AhmadElGendi

    AhmadElGendi New Member

    Hello !

    I followed :
    http://www.howtoforge.com/virtual-u...rier-mysql-and-squirrelmail-centos-6.0-x86_64

    Except:
    Page4:12 Install Amavisd-new, SpamAssassin And ClamAV
    Page 5:13 Install Razor, Pyzor And DCC And Configure SpamAssassin

    Which I dont want them for the moment


    My problem that I am unable to connect to server via POP or IMAP client as it keep asking me for the password.

    ------------------------------------------------------------------------------
    even through SquirrelMail I receive:
    ERROR: Connection dropped by IMAP server.

    reviewing : /var/log/messages
    I noticed:
    Dec 21 22:40:57 MyDomainName authdaemond: failed to connect to mysql server (server=localhost, userid=mail_admin): Access denied for user 'mail_admin'@'localhost' (using password: YES)
    Dec 21 22:40:57 MyDomainName postfix/smtpd[23400]: warning: SASL authentication failure: could not verify password

    ------------------------------------------------------------------------------
    Also when I try to send to it the get this delivery Error:

    Mail Delivery System [email protected] to me

    show details 1:23 AM (0 minutes ago)

    This is the mail system at host mail.MyDomain.Com.

    I'm sorry to have to inform you that your message could not
    be delivered to one or more recipients. It's attached below.

    For further assistance, please send mail to postmaster.

    If you do so, please include this problem report. You can
    delete your own text from the attached returned message.

    The mail system

    <[email protected]>: mail for mail.MyDomain.Com loops back to myself

    Final-Recipient: rfc822; [email protected]
    Original-Recipient: rfc822;[email protected]
    Action: failed
    Status: 5.4.6
    Diagnostic-Code: X-Postfix; mail for mail.MyDomain.Com loops back to myself
    --------------------------

    ----------------------------------------------------
    I did the telnet test
    telnet localhost 25
    as per: http://www.howtoforge.com/virtual-u...r-mysql-and-squirrelmail-centos-6.0-x86_64-p5
    ((


    If you see the lines

    250-STARTTLS

    and

    250-AUTH LOGIN PLAIN

    everything is fine.
    ))
    ----------------------------------------------------
    But it is not fine :D

    could any one assist me please ?
     
    Last edited: Dec 21, 2011
  2. falko

    falko Super Moderator Howtoforge Staff

    Please add mail.MyDomain.Com to the mydestination line in /etc/postfix/main.cf and restart Postfix.

    Do you use the correct password? Make sure there's no whitespace at the end of the MYSQL_USERNAME and MYSQL_PASSWORD lines.
     
  3. AhmadElGendi

    AhmadElGendi New Member

    First I appreciate your valuable time to answer me.

    Yes , the password was correct as I was able to log on MySql using MySql Query browser and remotely it was successfully logged on.
    also the files I made sure of the password:

    nano /etc/postfix/mysql-virtual_domains.cf

    user = mail_admin
    password = @XYZ99
    dbname = mail
    query = SELECT domain AS virtual FROM domains WHERE domain='%s'
    hosts = 127.0.0.1



    nano /etc/postfix/mysql-virtual_forwardings.cf
    user = mail_admin
    password = @XYZ99
    dbname = mail
    query = SELECT destination FROM forwardings WHERE source='%s'
    hosts = 127.0.0.1


    nano /etc/postfix/mysql-virtual_mailboxes.cf
    user = mail_admin
    password = @XYZ99
    dbname = mail
    query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s'
    hosts = 127.0.0.1



    nano /etc/postfix/mysql-virtual_email2email.cf
    user = mail_admin
    password = @XYZ99
    dbname = mail
    query = SELECT email FROM users WHERE email='%s'
    hosts = 127.0.0.1

    /etc/postfix/mysql-virtual_transports.cf
    user = mail_admin
    password = @XYZ99
    dbname = mail
    query = SELECT transport FROM transport WHERE domain='%s'
    hosts = 127.0.0.1



    /etc/postfix/mysql-virtual_mailbox_limit_maps.cf

    user = mail_admin
    password = @XYZ99
    dbname = mail
    query = SELECT quota FROM users WHERE email='%s'
    hosts = 127.0.0.1


    nano /etc/authlib/authmysqlrc
    MYSQL_SERVER localhost
    MYSQL_USERNAME mail_admin
    MYSQL_PASSWORD @XYZ99
    -------------
    Is the problem as my password starts with '@ ' ?
    or because of the space aster the '='

    Vielen Dank :)
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Yes, that might be the problem. Maybe you have to escape it with a backslash (or use another password).
    No, I don't think so.
     
  5. AhmadElGendi

    AhmadElGendi New Member

    Hello Falko

    I changed the password so it starts with a letter

    in: /var/log/maillog
    When I try to connect via OutlookExpress or Squirrel Mail I get the below log:
    ============================
    Dec 23 17:19:20 MyDomain imapd: Connection, ip=[::ffff:127.0.0.1]
    Dec 23 17:19:20 MyDomain authdaemond: failed to connect to mysql server (server=localhost, userid=mail_admin): Access denied for user 'mail_admin'@'localhost' (using password: YES)
    Dec 23 17:19:20 MyDomain imapd: LOGIN FAILED, [email protected], ip=[::ffff:127.0.0.1]
    Dec 23 17:19:20 MyDomain imapd: authentication error: Input/output error
    Dec 23 17:20:45 MyDomain pop3d: Connection, ip=[::ffff:109.161.165.113]
    Dec 23 17:20:45 MyDomain authdaemond: failed to connect to mysql server (server=localhost, userid=mail_admin): Access denied for user 'mail_admin'@'localhost' (using password: YES)
    Dec 23 17:20:45 MyDomain pop3d: LOGIN FAILED, [email protected], ip=[::ffff:109.151.145.213]
    Dec 23 17:20:45 MyDomain pop3d: authentication error: Input/output error
    Dec 23 17:21:18 MyDomain imapd: Connection, ip=[::ffff:127.0.0.1]
    Dec 23 17:21:18 MyDomain authdaemond: failed to connect to mysql server (server=localhost, userid=mail_admin): Access denied for user 'mail_admin'@'localhost' (using password: YES)
    Dec 23 17:21:18 MyDomain imapd: LOGIN FAILED, [email protected], ip=[::ffff:127.0.0.1]
    Dec 23 17:21:18 MyDomain imapd: authentication error: Input/output error
    ==============================

    **I believe that problem it uses: authdaemond that is not installed !
    service authdaemond restart
    authdaemond: unrecognized service
    but my Imap is using /etc/init.d/courier-authlib

    ** I feel that I imapd is unable to authenticate against mysql !!

    ** I have stopped iptables as well but sounds like there is something stopping SMTP for remote telnet !!

    ** using mailx to Send A Welcome Email For Creating Maildir, I noted that no mail directories are created under /home/vmail !!
    Any Idea ?
     
    Last edited: Dec 23, 2011
  6. falko

    falko Super Moderator Howtoforge Staff

    Can you log into MySQL like this?
    Code:
    mysql -u mail_admin -p
     
  7. AhmadElGendi

    AhmadElGendi New Member

    ---> mysql -u mail_admin -p
    Yes I was able to locally and remotely login with the mail_admin password.

    ----------------------------------------------
    For squirrel I see the change_sqlpass plugin is there but I believe it is not working although I did follow the article but it looks not working as expected

    Plugins
    Installed Plugins
    1. delete_move_next
    2. squirrelspell
    3. newmail
    4. compatibility
    5. change_sqlpass

    =========================
    SquirrelMail configtest

    This script will try to check some aspects of your SquirrelMail configuration and point you to errors whereever it can find them. You need to go run conf.pl in the config/ directory first before you run this script.

    SquirrelMail version: 1.4.22-2.el6
    Config file version: 1.4.0
    Config file last modified: 24 December 2011 08:31:29
    Checking PHP configuration...
    PHP version 5.3.3 OK.
    Running as N/A(N/A) / N/A(N/A)
    display_errors:
    error_reporting: 22527
    variables_order OK: GPCS.
    PHP extensions OK. Dynamic loading is disabled.

    ERROR: You have configured PHP not to allow short tags (short_open_tag=off). This shouldn't be a problem with SquirrelMail or any plugin coded coded according to the SquirrelMail Coding Guidelines, but if you experience problems with PHP code being displayed in some of the pages and changing setting to "on" solves the problem, please file a bug report against the failing plugin. The correct contact information is most likely to be found in the plugin documentation.
    Checking paths...
    Data dir OK.
    Attachment dir OK.
    Plugins OK.
    Themes OK.
    Default language OK.
    Base URL detected as: https://86.143.157.79/webmail/src (location base autodetected)
    Checking outgoing mail service....
    sendmail OK
    Checking IMAP service....
    IMAP server ready (* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. See COPYING for distribution information.)
    Capabilities: * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS
    Checking internationalization (i18n) settings...
    gettext - Gettext functions are available. On some systems you must have appropriate system locales compiled.
    mbstring - Mbstring functions are available.
    recode - Recode functions are unavailable.
    iconv - Iconv functions are available.
    timezone - Webmail users can change their time zone settings.
    Checking database functions...
    not using database functionality.
    =========================


    see the config above , it can not detect the DB funstionality functionality, thats why I get:

    ERROR: Connection dropped by IMAP server.


    Falko can I send you logins in private message ?
     
    Last edited: Dec 24, 2011
  8. falko

    falko Super Moderator Howtoforge Staff

    My guess is that you left out important parts of the tutorial, but it's hard for me to tell where the error is. If you follow the tutorial from beginning to end, everything should be fine (it's working for me).
     
  9. White

    White Member

    have you set your router to allow traffic to the ports 110 and 25 also 10025
     

Share This Page