Postfix stop working, email stuck in queue

dedicated-serverpostfixqueue

Few day ago i recognize that my postfix have 600 000 mail in queue. The causes was php files in one of my domains. I removed this php files, flush postfix queue and block ip adress which access to this php files.

At this moment i have 200 emails in my queue. I can't send any email for three days. I check my ip on Blacklist and ip address is clear.

Postfix version 2.7
Dedicated server

    qmail 
     .
     .
     .
     4AB48A08BA      903 Wed Feb 12 22:43:55  xxxxx@xxxxxxxx.ovh.net
     (delivery temporarily suspended: connect to
     mx5.wp.pl[212.77.101.13]:25: Connection timed o ut)
                                              aaaaaaa@aaaaaa.pl
     .
     .
     .
    -- 285 Kbytes in 236 Requests.




    qshape deferred

                                              T  5 10 20 40 80 160 320 640 1280 1280+
                                      TOTAL 230  0  0  1  1  0   6   6  12  109    95
                                  gmail.com  68  0  0  1  0  0   1   3   4   28    31
                                      wp.pl  64  0  0  0  0  0   1   0   0   32    31
                                      o2.pl  22  0  0  0  0  0   1   3   0    9     9
                                 interia.pl  12  0  0  0  1  0   0   0   1   10     0
                                      op.pl  11  0  0  0  0  0   0   0   0    7     4
                                    onet.pl  10  0  0  0  0  0   2   0   0    6     2
                                      vp.pl   6  0  0  0  0  0   0   0   0    4     2
                                    tlen.pl   5  0  0  0  0  0   0   0   1    2     2
                                hotmail.com   5  0  0  0  0  0   0   0   1    0     4
                             poczta.onet.pl   4  0  0  0  0  0   0   0   0    4     0
                                  gazeta.pl   2  0  0  0  0  0   0   0   2    0     0
                                onet.com.pl   2  0  0  0  0  0   0   0   0    1     1
                                       p.pl   1  0  0  0  0  0   0   0   0    1     0
                                     gmx.at   1  0  0  0  0  0   0   0   0    0     1
                                     web.de   1  0  0  0  0  0   0   0   0    0     1
                                     go2.pl   1  0  0  0  0  0   0   0   1    0     0
                                     hot.pl   1  0  0  0  0  0   0   0   0    1     0
                                    onet.eu   1  0  0  0  0  0   0   0   0    0     1
                                   yahoo.ca   1  0  0  0  0  0   0   0   1    0     0

     mail.info
     NsXXXXX postfix/qmgr[15761]: AD4FCA06C0:
     from=<mydomain@nsXXXXX.ovh.net, size=961, nrcpt=1 (queue active)
     NsXXXXX postfix/qmgr[15761]: 76192A091C:
     from=<mydomain@nsXXXXX.ovh.net, size=648, nrcpt=1 (queue active)
     NsXXXXX postfix/qmgr[15761]: 79615A10BB:
     from=<mydomain2@nsXXXXX.ovh.net, size=746, nrcpt=1 (queue active)
     NsXXXXX postfix/error[22420]: 120E1A11D4:
     to=<eliasz.kubala@gmail.com, relay=none, delay=476, delays=476/0/0/0,
     dsn=4.4.1, status=deferred (delivery temporarily suspended:$ NsXXXXX
     postfix/qmgr[15761]: 95C20A107E: from=<mydomain@nsXXXXX.ovh.net,
     size=912, nrcpt=1 (queue active) NsXXXXX postfix/qmgr[15761]:
     96E59A11C0: from=<mydomain@nsXXXXX.ovh.net, size=899, nrcpt=1 (queue
     active) NsXXXXX postfix/qmgr[15761]: B8DDCA090D:
     from=<mydomain@nsXXXXX.ovh.net, size=897, nrcpt=1 (queue active)
     NsXXXXX postfix/qmgr[15761]: B50F3A06C7:
     from=<mydomain@nsXXXXX.ovh.net, size=963, nrcpt=1 (queue active)
     NsXXXXX postfix/error[24540]: 76192A091C: to=<sylvasster@gmail.com,
     relay=none, delay=86554, delays=86554/0/0/0, dsn=4.4.1,
     status=deferred (delivery temporarily suspended$ NsXXXXX
     postfix/qmgr[15761]: 6DE65A06FA: from=<mydomain@nsXXXXX.ovh.net,
     size=903, nrcpt=1 (queue active) NsXXXXX postfix/qmgr[15761]:
     8E5C6A1053: from=<mydomain@nsXXXXX.ovh.net, size=645, nrcpt=1 (queue
     active) NsXXXXX postfix/error[22420]: 79615A10BB:
     to=<eliasz.kubala@gmail.com, relay=none, delay=14451,
     delays=14451/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily
     suspen$ NsXXXXX postfix/qmgr[15761]: 89FC7A10D4:
     from=<mydomain@nsXXXXX.ovh.net, size=912, nrcpt=1 (queue active)
     NsXXXXX postfix/qmgr[15761]: 87B01A0E9C:
     from=<mydomain@nsXXXXX.ovh.net, size=642, nrcpt=1 (queue active)
     NsXXXXX postfix/error[24540]: B50F3A06C7: to=<Lubiezozole@gmail.com,
     relay=none, delay=86684, delays=86684/0/0/0, dsn=4.4.1,
     status=deferred (delivery temporarily suspende$ NsXXXXX
     postfix/qmgr[15761]: 0EC70A0945: from=<mydomain@nsXXXXX.ovh.net,
     size=657, nrcpt=1 (queue active) Feb 14 00:09:48 nsXXXXX
     postfix/smtp[24546]: connect to mx.interia.pl[217.74.65.64]:25:
     Connection timed out Feb 14 00:09:48 nsXXXXX postfix/smtp[24551]:
     89FC7A10D4: to=<karinanie17@interia.pl, relay=none, delay=13087,
     delays=13057/0.01/30/0, dsn=4.4.1, status=deferred (connect to
     mx.interia.pl[$ Feb 14 00:09:48 nsXXXXX postfix/smtp[24549]: connect
     to mx-eu.mail.am0.yahoodns.net[188.125.69.79]:25: Connection timed out
     Feb 14 00:09:48 nsXXXXX postfix/smtp[24549]: 6DE65A06FA:
     to=<blu1470@yahoo.co.uk, relay=none, delay=96964,
     delays=96934/0.01/30/0, dsn=4.4.1, status=deferred (connect to
     mx-eu.mail.am0.ya$ Feb 14 00:09:48 nsXXXXX postfix/smtp[24553]:
     connect to smtp.hosting.tp.pl[193.110.120.2]:25: Connection timed out
     Feb 14 00:09:48 nsXXXXX postfix/smtp[24539]: connect to
     mx.poczta.onet.pl[213.180.147.146]:25: Connection timed out Feb 14
     00:09:48 nsXXXXX postfix/smtp[24553]: 0EC70A0945:
     to=<krzysztof.rogoz@neostrada.pl, relay=none, delay=55165,
     delays=55135/0.02/30/0, dsn=4.4.1, status=deferred (connect to
     smtp.hos$ Feb 14 00:09:48 nsXXXXX postfix/smtp[24539]: C8D84A06DF:
     to=<banasmarcin77@onet.eu, relay=none, delay=103556,
     delays=103526/0/30/0, dsn=4.4.1, status=deferred (connect to
     mx.poczta.onet.p$ Feb 14 00:09:48 nsXXXXX postfix/smtp[24544]: connect
     to mx.poczta.onet.pl[213.180.147.146]:25: Connection timed out Feb 14
     00:09:48 nsXXXXX postfix/smtp[24544]: 3B8B0A1056:
     to=<annina777@op.pl, relay=none, delay=19473, delays=19443/0.01/30/0,
     dsn=4.4.1, status=deferred (connect to mx.poczta.onet.pl[213$ Feb 14
     00:09:48 nsXXXXX postfix/smtp[24541]: connect to
     mx.poczta.onet.pl[213.180.147.146]:25: Connection timed out Feb 14
     00:09:48 nsXXXXX postfix/smtp[24541]: D6E98A06F7: to=<makowa4@op.pl,
     relay=none, delay=97063, delays=97033/0/30/0, dsn=4.4.1,
     status=deferred (connect to mx.poczta.onet.pl[213.180.$ Feb 14
     00:09:49 nsXXXXX postfix/smtp[24550]: connect to
     mx.poczta.onet.pl[213.180.147.146]:25: Connection timed out Feb 14
     00:09:49 nsXXXXX postfix/smtp[24550]: 8E5C6A1053:
     to=<mark54@poczta.onet.pl, relay=none, delay=11112,
     delays=11082/0.01/30/0, dsn=4.4.1, status=deferred (connect to
     mx.poczta.onet.$ Feb 14 00:10:01 nsXXXXX postfix/pickup[13908]:
     E28C4A10B1: uid=33 from=<www-data Feb 14 00:10:01 nsXXXXX
     postfix/cleanup[25085]: E28C4A10B1:
     message-id=<20140213231001.E28C4A10B1@nsXXXXX.ovh.net Feb 14 00:10:01
     nsXXXXX postfix/qmgr[15761]: E28C4A10B1:
     from=<www-data@nsXXXXX.ovh.net, size=856, nrcpt=1 (queue active) Feb
     14 00:10:01 nsXXXXX postfix/local[25088]: E28C4A10B1:
     to=<www-data@nsXXXXX.ovh.net, orig_to=<www-data, relay=local,
     delay=0.02, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (delivere$
     Feb 14 00:10:01 nsXXXXX postfix/qmgr[15761]: E28C4A10B1: removed

     postfix status
     postfix/postfix-script: the Postfix mail system is running: PID: 18172


    postconf -n
     alias_database = hash:/etc/aliases
     alias_maps = hash:/etc/aliases
     allow_percent_hack = no
     append_dot_mydomain = no
     biff = no
     broken_sasl_auth_clients = yes
     config_directory = /etc/postfix
     home_mailbox = Maildir/
     inet_interfaces = all
     mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
     mailbox_size_limit = 0
     mydestination = nsXXXXX.ovh.net, localhost.ovh.net, , localhost
     myhostname = nsXXXXX.ovh.net
     mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
     myorigin = /etc/mailname
     readme_directory = no
     recipient_delimiter = +
     relayhost =
     sender_bcc_maps = hash:/etc/postfix/bcc
     smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
     smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
     smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
     smtpd_sasl_auth_enable = yes
     smtpd_sasl_security_options = noanonymous
     smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
     smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
     smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
     smtpd_use_tls = yes
     virtual_alias_maps = hash:/etc/postfix/virtual




mail.log
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 9DD39A1837: from=<iptak@nsXXXXX.ovh.net>, size=898, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10491]: 71BD6A1120: to=<slawomirpoznan@wp.pl>, relay=none, delay=128077, delays=128077/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspend$
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 9C7DBA1312: from=<iptak@nsXXXXX.ovh.net>, size=647, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: B251AA15C3: from=<iptak@nsXXXXX.ovh.net>, size=911, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: B267AA107D: from=<iptak@nsXXXXX.ovh.net>, size=954, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: B4CC6A196E: from=<serialowisko@nsXXXXX.ovh.net>, size=1753, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10500]: 9DD39A1837: to=<alaskan19@wp.pl>, relay=none, delay=185188, delays=185188/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: c$
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: BB322A16DB: from=<iptak@nsXXXXX.ovh.net>, size=946, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10494]: B251AA15C3: to=<jolajolanta5@wp.pl>, relay=none, delay=115404, delays=115404/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended$
Feb  9 00:01:38 nsXXXXX postfix/error[10488]: 9C7DBA1312: to=<twojmareczek@wp.pl>, relay=none, delay=29957, delays=29957/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: $
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 64B14A1329: from=<iptak@nsXXXXX.ovh.net>, size=641, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10487]: B267AA107D: to=<zuziaczek101@wp.pl>, relay=none, delay=88732, delays=88732/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: $
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 896C6A164F: from=<iptak@nsXXXXX.ovh.net>, size=646, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10491]: BB322A16DB: to=<ania23412@wp.pl>, relay=none, delay=96967, delays=96967/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: con$
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 205E1A186F: from=<iptak@nsXXXXX.ovh.net>, size=648, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 218D5A194F: from=<iptak@nsXXXXX.ovh.net>, size=639, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10496]: 64B14A1329: to=<karolcia93c@wp.pl>, relay=none, delay=34052, delays=34052/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: c$
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 02D84A1766: from=<iptak@nsXXXXX.ovh.net>, size=966, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 06A0AA1033: from=<iptak@nsXXXXX.ovh.net>, size=971, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 0DEB2A0F97: from=<iptak@nsXXXXX.ovh.net>, size=637, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10494]: 218D5A194F: to=<grzes_k@wp.pl>, relay=none, delay=315425, delays=315425/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: con$
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 0F1B1A10EA: from=<iptak@nsXXXXX.ovh.net>, size=908, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 4FD3FA19DE: from=<iptak@nsXXXXX.ovh.net>, size=651, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 485BFA16AF: from=<iptak@nsXXXXX.ovh.net>, size=896, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 46CF7A141A: from=<iptak@nsXXXXX.ovh.net>, size=908, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 46377A112C: from=<iptak@nsXXXXX.ovh.net>, size=652, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/qmgr[3686]: 4C90FA1847: from=<iptak@nsXXXXX.ovh.net>, size=645, nrcpt=1 (queue active)
Feb  9 00:01:38 nsXXXXX postfix/error[10487]: 0DEB2A0F97: to=<ankal75@wp.pl>, relay=none, delay=55200, delays=55200/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: conne$
Feb  9 00:01:38 nsXXXXX postfix/error[10494]: 485BFA16AF: to=<kajompa@wp.pl>, relay=none, delay=130642, delays=130642/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: con$
Feb  9 00:01:38 nsXXXXX postfix/error[10500]: 4C90FA1847: to=<karooolkaaa123@wp.pl>, relay=none, delay=6211, delays=6211/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: $
Feb  9 00:02:01 nsXXXXX postfix/pickup[6932]: B5762A1068: uid=1000 from=<iptak>
Feb  9 00:02:01 nsXXXXX postfix/cleanup[11163]: B5762A1068: message-id=<20140208230201.B5762A1068@nsXXXXX.ovh.net>
Feb  9 00:02:01 nsXXXXX postfix/qmgr[3686]: B5762A1068: from=<iptak@nsXXXXX.ovh.net>, size=1184, nrcpt=1 (queue active)
Feb  9 00:02:07 nsXXXXX postfix/local[11164]: B5762A1068: to=<iptak@nsXXXXX.ovh.net>, orig_to=<iptak>, relay=local, delay=5.5, delays=0.01/0/0/5.5, dsn=2.0.0, status=sent (delivered to com$
Feb  9 00:02:07 nsXXXXX postfix/qmgr[3686]: B5762A1068: removed
Feb  9 00:02:08 nsXXXXX postfix/smtp[10489]: connect to mx.interia.pl[217.74.65.64]:25: Connection timed out
Feb  9 00:02:08 nsXXXXX postfix/smtp[10486]: connect to mx.interia.pl[217.74.65.64]:25: Connection timed out
Feb  9 00:02:08 nsXXXXX postfix/smtp[10489]: 537ABA19CD: to=<marcinkosmala@interia.pl>, relay=none, delay=281882, delays=281852/0/30/0, dsn=4.4.1, status=deferred (connect to mx.interia.pl$
Feb  9 00:02:08 nsXXXXX postfix/smtp[10486]: 5DABEA11A2: to=<gwizdol@interia.pl>, relay=none, delay=361807, delays=361777/0/30/0, dsn=4.4.1, status=deferred (connect to mx.interia.pl[217.7$
Feb  9 00:02:08 nsXXXXX postfix/smtp[10495]: connect to mx6.go2.pl[193.17.41.46]:25: Connection timed out
Feb  9 00:02:08 nsXXXXX postfix/smtp[10502]: connect to mx.interia.pl[217.74.65.64]:25: Connection timed out
Feb  9 00:02:08 nsXXXXX postfix/smtp[10502]: C3C54A0A40: to=<paulina200130@interia.pl>, relay=none, delay=219030, delays=219000/0.01/30/0, dsn=4.4.1, status=deferred (connect to mx.interia$
Feb  9 00:02:08 nsXXXXX postfix/error[10488]: 02D84A1766: to=<zbigniewbart@interia.pl>, relay=none, delay=134849, delays=134819/30/0/0, dsn=4.4.1, status=deferred (delivery temporarily sus$
Feb  9 00:02:08 nsXXXXX postfix/error[10496]: 4FD3FA19DE: to=<krecik202720@interia.pl>, relay=none, delay=277659, delays=277629/30/0/0, dsn=4.4.1, status=deferred (delivery temporarily sus$

Best Answer

As I see the problem only with gmail and wp.pl. I would suggest to try emulate smtp session from console

# telnet mx.wp.pl 25
Trying 212.77.101.4...
Connected to mx.wp.pl.
Escape character is '^]'.
220 mx.wp.pl ESMTP
ehlo nsXXXXX.ovh.net

For gmail something like the following

# openssl s_client -connect smtp.gmail.com:465
...

---
220 mx.google.com ESMTP cl5sm5470537lbb.14 - gsmtp
ehlo nsXXXXX.ovh.net
250-mx.google.com at your service, [xxx.xxx.xxx.xxx]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
250-ENHANCEDSTATUSCODES
250 CHUNKING
quit
221 2.0.0 closing connection cl5sm5470537lbb.14 - gsmtp
read:errno=0

Also check your ip in blacklist, for e.g. http://mxtoolbox.com/SuperTool.aspx?action=blacklist