IMAP not downloading mail (Postfix/Courier/mySQL setup)

Discussion in 'HOWTO-Related Questions' started by suaswe, May 23, 2012.

  1. suaswe

    suaswe New Member

    Hi all!

    I recently followed the 'Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 6.2 x86_64)' guide, and after a lot of graft I have now got the server to a point where I can send and receive mail internally and externally and load the Squirrelmail webpage; however, just as a cruel last little stumbling block, I have discovered here on the home straight that I am not receiving any mail into IMAP since yesterday afternoon, meaning that whilst I can send mail from Squirrelmail, I do not receive any there.

    Now, I wish I could tell you what changes I made yesterday afternoon to allow it to briefly work for a few hours before stopping again, but alas, I have made so many changes before and since that I really have no clue. At the time when mail was coming in, yesterday 11am-1pm approx, Squirrelmail wasn't yet loading so I wasn't aware that it was downloading anything.

    The failure to download anything into Squirrelmail comes from the fact that IMAP isn't receiving anything new (the six e-mails in the inbox below are the ones that came in yesterday):

    Code:
    telnet mydomain.com 143
    Trying x.x.x.x...
    Connected to mydomain.com.
    Escape character is '^]'.
    * 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.
    0 login user1[a]mydomain.com passwd
    0 OK LOGIN Ok.
    0 select inbox
    * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
    * OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited
    * 6 EXISTS
    * 0 RECENT
    * OK [UIDVALIDITY 1337763508] Ok
    * OK [MYRIGHTS "acdilrsw"] ACL
    0 OK [READ-WRITE] Ok
    
    The home dir as per authmysqlrc and main.cf is /home/vmail, as suggested by the how-to guide:

    Code:
    sudo cat /etc/authlib/authmysqlrc| grep HOME
    MYSQL_HOME_FIELD "/home/vmail"
    
    cat /etc/postfix/main.cf | grep vmail
    virtual_mailbox_base = /home/vmail
    
    Looking in the relevant subdirectory in /home/vmail, I can see the six e-mails also visible in IMAP/Squirrelmail, but no others:

    Code:
    ll /home/vmail/mydomain.com/user1/cur/*
    -rw------- 1 vmail vmail 1295 May 22 11:39 /home/vmail/mydomain.com/user1/cur/1337683182.Vfd02I1920008M825692.mydomain.com:2,S
    -rw------- 1 vmail vmail 1119 May 22 11:40 /home/vmail/mydomain.com/user1/cur/1337683234.Vfd02I192000bM642814.mydomain.com:2,S
    -rw------- 1 vmail vmail 1119 May 22 11:49 /home/vmail/mydomain.com/user1/cur/1337683763.Vfd02I192000cM274064.mydomain.com:2,S
    -rw------- 1 vmail vmail 1110 May 22 11:49 /home/vmail/mydomain.com/user1/cur/1337683769.Vfd02I192000dM508512.mydomain.com:2,S
    -rw------- 1 vmail vmail 1132 May 22 13:24 /home/vmail/mydomain.com/user1/cur/1337689465.Vfd02I192000eM45146.mydomain.com:2,S
    -rw------- 1 vmail vmail 1133 May 22 13:27 /home/vmail/mydomain.com/user1/cur/1337689623.Vfd02I192000fM33886.mydomain.com:2,S
    
    I have sent ample test e-mails since this and they are appearing in /var/spool/mail/user1 rather than /home/vmail, which I take it is wrong? I would be very grateful if someone could help me with this!
     
    Last edited by a moderator: May 24, 2012
  2. falko

    falko Super Moderator

    Are there any errors in your mail log (in the /var/log/ directory)?

    Did you compare your main.cf with the one from the tutorial?
     
  3. suaswe

    suaswe New Member

    Hi Falko,

    Thanks so much for replying!

    I have pasted my postconf -n output below; have scoured it myself and compared it to what the guide suggests and from what I know, it looks correct - what are your thoughts?

    The logs in maillog don't really reveal anything: when attempting to "download" mail to Squirrelmail I just get the following:

    Code:
    May 24 13:49:27 mydomain imapd: Connection, ip=[::ffff:x.x.x.x]
    May 24 13:49:27 mydomain imapd: LOGIN, user=user1@mydomain.com, ip=[::ffff:x.x.x.x], port=[48761], protocol=IMAP
    May 24 13:49:27 mydomain imapd: LOGOUT, user=user1@mydomain.com, ip=[::ffff:x.x.x.x], headers=0, body=0, rcvd=87, sent=391, time=0
    
    .. and that's the only kind of entry I get for imapd, just logging in and logging out.

    Postfix -n looks like this:

    Code:
    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
    data_directory = /var/lib/postfix
    debug_peer_level = 2
    html_directory = no
    inet_interfaces = all
    inet_protocols = all
    mail_owner = postfix
    mailq_path = /usr/bin/mailq.postfix
    manpage_directory = /usr/share/man
    mydestination = mydomain.com, localhost, localhost.localdomain
    myhostname = mydomain.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.6.6/README_FILES
    receive_override_options = no_address_mappings
    sample_directory = /usr/share/doc/postfix-2.6.6/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_sasl_authenticated_header = yes
    smtpd_tls_cert_file = /etc/postfix/mydomain.com.crt
    smtpd_tls_key_file = /etc/postfix/mydomain.com.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_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
    virtual_uid_maps = static:5000
    
    Another weirdness is that I'm still also getting entries for sendmail when sending, and if I disable /usr/sbin/sendmail using chown or try to remove the sendmail package, I can no longer send mail using mailx. Is this a sendmail function within postfix (such as what postconf -n seems to be referring to above) or is something playing havoc? Typical mail trace when sending looks like:

    Code:
    May 24 13:52:51 mydomain sendmail[11975]: q4OCqpcd011975: from=user1, size=214, class=0, nrcpts=1, msgid=<201205241252.q4OCqpcd011975@mydomain.com>, relay=user1@localhost
    May 24 13:52:51 mydomain postfix/smtpd[11976]: connect from localhost[127.0.0.1]
    May 24 13:52:51 mydomain sendmail[11975]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
    May 24 13:52:51 mydomain postfix/trivial-rewrite[11978]: warning: do not list domain mydomain.com in BOTH mydestination and virtual_mailbox_domains
    May 24 13:52:51 mydomain postfix/smtpd[11976]: ABF081E0E64: client=localhost[127.0.0.1], sasl_sender=user1@mydomain.com
    May 24 13:52:51 mydomain postfix/cleanup[11983]: ABF081E0E64: message-id=<201205241252.q4OCqpcd011975@mydomain.com>
    May 24 13:52:51 mydomain postfix/qmgr[4104]: ABF081E0E64: from=<user1@mydomain.com>, size=630, nrcpt=1 (queue active)
    May 24 13:52:51 mydomain sendmail[11975]: q4OCqpcd011975: to=user1@mydomain.com, ctladdr=user1 (500/5001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30214, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as ABF081E0E64)
    May 24 13:52:51 mydomain postfix/smtpd[11976]: warning: network_biopair_interop: error reading 5 bytes from the network: Connection reset by peer
    May 24 13:52:51 mydomain postfix/smtpd[11976]: disconnect from localhost[127.0.0.1]
    
    I'm not exactly sure what the verify=FAIL error is about, nor the warning regarding "do not list domain mydomain.com in BOTH mydestination and virtual_mailbox_domains"; if I remove mydomain.com from mydestination, I can no longer send mail.

    I feel very tangled up here, would love some assistance if you're able!
     
  4. falko

    falko Super Moderator

  5. suaswe

    suaswe New Member

    Heh, I think maybe I've been an idiot: I tried removing my domain name from mydestination when I saw the error message initially, then tested whether it had worked by... using the mail function, which checks /var/spool/mail... Sigh! I think I get it now: when it's working correctly, mail will *not* end up there, kind of the whole point is that they'll go to /home/vmail instead - am-I-rite? Phiew, so it now seems to be working, getting mail into Squirrelmail and everything!

    Now I just have one remianing query really: sendmail is still very much on my system, and in fact has reappeared as switched on in chkconfig a couple of times even after I've disabled it; similarly, postfix has gone off even though I've expressly switched it on. Also, I'm still seeing sendmail in my logs:

    Code:
    May 25 08:41:06 mydomain sendmail[1760]: q4P7f6Ql001760: from=user1, size=215, class=0, nrcpts=1, msgid=<201205250741.q4P7f6Ql001760@mydomain.com>, relay=user1@localhost
    May 25 08:41:06 mydomain postfix/smtpd[1762]: connect from localhost[127.0.0.1]
    May 25 08:41:06 mydomain sendmail[1760]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
    May 25 08:41:06 mydomain postfix/smtpd[1762]: E97C01E0CF3: client=localhost[127.0.0.1], sasl_sender=user1@mydomain.com
    May 25 08:41:06 mydomain postfix/cleanup[1766]: E97C01E0CF3: message-id=<201205250741.q4P7f6Ql001760@mydomain.com>
    May 25 08:41:07 mydomain postfix/qmgr[1398]: E97C01E0CF3: from=<user1@mydomain.com>, size=641, nrcpt=1 (queue active)
    May 25 08:41:07 mydomain sendmail[1760]: q4P7f6Ql001760: to=postmaster@mydomain.com, ctladdr=user1 (500/5001), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30215, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as E97C01E0CF3)
    May 25 08:41:07 mydomain amavis[1479]: (01479-02) NOTICE: reconnecting in response to: err=2006, HY000, DBD::mysql::st execute failed: MySQL server has gone away at (eval 100) line 166, <GEN30> line 5.
    May 25 08:41:07 mydomain postfix/smtpd[1762]: warning: network_biopair_interop: error reading 5 bytes from the network: Connection reset by peer
    May 25 08:41:07 mydomain postfix/smtpd[1762]: disconnect from localhost[127.0.0.1]
    May 25 08:41:08 mydomain postfix/smtpd[1773]: connect from unknown[127.0.0.1]
    May 25 08:41:08 mydomain postfix/smtpd[1773]: 0736F1E0B1A: client=unknown[127.0.0.1]
    May 25 08:41:08 mydomain postfix/cleanup[1766]: 0736F1E0B1A: message-id=<201205250741.q4P7f6Ql001760@mydomain.com>
    May 25 08:41:08 mydomain postfix/smtpd[1773]: disconnect from unknown[127.0.0.1]
    May 25 08:41:08 mydomain postfix/qmgr[1398]: 0736F1E0B1A: from=<user1@mydomain.com>, size=1068, nrcpt=1 (queue active)
    May 25 08:41:08 mydomain amavis[1479]: (01479-02) Passed CLEAN, MYNETS LOCAL [127.0.0.1] [127.0.0.1] <user1@mydomain.com> -> <postmaster@mydomain.com>, Message-ID: <201205250741.q4P7f6Ql001760@mydomain.com>, mail_id: UhA2vFoZ4snR, Hits: -1, size: 641, queued_as: 0736F1E0B1A, 1047 ms
    May 25 08:41:08 mydomain postfix/smtp[1767]: E97C01E0CF3: to=<postmaster@mydomain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=1.2, delays=0.12/0.01/0.01/1.1, dsn=2.0.0, status=sent (250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 0736F1E0B1A)
    May 25 08:41:08 mydomain postfix/qmgr[1398]: E97C01E0CF3: removed
    May 25 08:41:08 mydomain postfix/virtual[1775]: 0736F1E0B1A: to=<user1@mydomain.com>, orig_to=<postmaster@mydomain.com>, relay=virtual, delay=0.17, delays=0.07/0.02/0/0.09, dsn=2.0.0, status=sent (delivered to maildir)
    May 25 08:41:08 mydomain postfix/qmgr[1398]: 0736F1E0B1A: removed
    May 25 08:41:48 mydomain postfix/smtpd[1746]: timeout after END-OF-MESSAGE from unknown[127.0.0.1]
    May 25 08:41:48 mydomain postfix/smtpd[1746]: disconnect from unknown[127.0.0.1]
    
    Is this normal?
     
  6. falko

    falko Super Moderator

    I'd try to uninstall Sendmail.
     
  7. suaswe

    suaswe New Member

    Hi falko,

    I have tried this however doing so causes sending mail to no longer work. Did 'yum remove sendmail' then tried to send in Squirrelmail:

    ******
    Message not sent. Server replied:

    Email delivery error
    127 Can't execute command '/usr/sbin/sendmail -i -t -fuser1@mydomain.com'.
    ******

    So sending is still relying on sendmail, from what I can tell. Any ideas?

    Cheers!

    suaswe
     
  8. falko

    falko Super Moderator

    Seems as if Postfix isn't fully installed (it comes with its own sendmail tool to be compatible with Sendmail). Please try to reinstall Postfix.
     
  9. suaswe

    suaswe New Member

    Hi there falko,

    I removed postfix (yum remove), installed it again (yum install) and removed sendmail (yum remove). Since doing this, I can no longer send mail via Squirrelmail; e-mails sent from there seem to disappear, and I'm not getting any logs to indicate send attemps. E-mails sent by mailx go to /var/spool/mail instead of /home/vmail.

    No configuration changes have been made in /etc/postfix/* - do you know what might be causing this?
     
  10. suaswe

    suaswe New Member

    OK, managed to sort this - when reinstalling Postfix I backed up all settings in /etc/postfix/*, then once installing I checked whether the settings were correctly retained. The mysql files and all that had been so didn't bother restoring from backup, but it seems main.cf may somehow not have been as the "inet_interfaces=all" line was commented out and it was instead just listening on local. Have now restored config from backup and everything is looking good, with no Sendmail involved! Cheers for your help. :)
     
  11. suaswe

    suaswe New Member

    PS. How do I mark this as solved?
     
  12. falko

    falko Super Moderator

    You can add "[SOLVED]" at the beginning of the thread title.
     

Share This Page