1

Topic: error: notify_quarantined_recipients.py --force-all

==== Required information ====
- iRedMail version (check /etc/iredmail-release):
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
======== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7
- Linux/BSD distribution name and version: Ubuntu 16.04.2 LTS
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? yes 2.9.0
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hi,

when running

root@mail:/opt/www/iredadmin/tools# python notify_quarantined_recipients.py --force-all

I got the following error:

* 24 users are willing to receive notification email.
Traceback (most recent call last):
  File "notify_quarantined_recipients.py", line 301, in <module>
    time_tuple = time.strptime(time_with_tz, '%Y-%m-%d %H:%M:%S')
  File "/usr/lib/python2.7/_strptime.py", line 478, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.7/_strptime.py", line 329, in _strptime
    found = format_regex.match(data_string)
TypeError: expected string or buffer

Can you help me please?

BG
Günther

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: error: notify_quarantined_recipients.py --force-all

Seems the data it got has some problem. It's hard for me to troubleshoot without direct ssh access and modify the source code. Contact us: http://www.iredmail.org/contact.html

3

Re: error: notify_quarantined_recipients.py --force-all

hi
on iRedMail-0.9.7 + Pro V2.7 running on Debian v7.11 - upgraded since well since forever smile

same issue here:
/usr/share/apache2/iredadmin/tools# python notify_quarantined_recipients.py --force-all
* 235 users are willing to receive notification email.
Traceback (most recent call last):
  File "notify_quarantined_recipients.py", line 301, in <module>
    time_tuple = time.strptime(time_with_tz, '%Y-%m-%d %H:%M:%S')
  File "/usr/lib/python2.7/_strptime.py", line 467, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.7/_strptime.py", line 322, in _strptime
    found = format_regex.match(data_string)
TypeError: expected string or buffer


I suspect - but can only guess that some domains have a defined timezone in their settings and some (most) don't and I guess this fails.

4

Re: error: notify_quarantined_recipients.py --force-all

*) If you're familiar with Python, could you try to add some 'print' command to print the data for troubleshooting?
*) If it possible to give me direct ssh access (with root privilege) to debug it on your server?

5 (edited by hk@ 2017-07-28 20:20:51)

Re: error: notify_quarantined_recipients.py --force-all

well, so I take my debugging hat and analyze the issue:

I added a "print time_with_tz" after "time_with_tz = utc_to_timezone(dt=dt, timezone=settings.LOCAL_TIMEZONE)"

and added some error handling as well as type conversion to string for the for the value returned by utc_to_timezone:

        # hk debug:
        print time_with_tz

        try:
          time_tuple = time.strptime(str(time_with_tz), '%Y-%m-%d %H:%M:%S')
          print (time_tuple)
        except ValueError as err:
                print(time_tuple,err)

this is a step forward, but when it comes to mail_body generation we hit another roadblock:

Traceback (most recent call last):
  File "notify_quarantined_recipients.py", line 347, in <module>
    mail_body = mail_body_template % {'quar_mail_info': quar_mail_info.encode('utf-8'),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 119: ordinal not in range(128)

regards
hk

6

Re: error: notify_quarantined_recipients.py --force-all

in order to fix this UnicodeDecodeError I tried several options:

like changing the whole line to:
mail_body = mail_body_template % {'quar_mail_info': quar_mail_info.encode(encoding='UTF-8',errors='ignore'),

strangely enough - this didn't help.

therefore I checked this whole block into error-handling, not ideal, but at least it doesn't kill itself:

    try:
        mail_body = mail_body_template % {'quar_mail_info': quar_mail_info.encode(encoding='UTF-8',errors='ignore'),
                                      'quar_keep_days': settings.AMAVISD_REMOVE_QUARANTINED_IN_DAYS,
                                      'iredadmin_url': iredadmin_url,
                                      'timezone': settings.LOCAL_TIMEZONE}
    except ValueError as err:
      print (err)

also regarding new characterset-domainnames I'd suggest to plan for this in future url-handlings, I kind of bet this might break things here also.

regards
hk

7

Re: error: notify_quarantined_recipients.py --force-all

hk@ wrote:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 119: ordinal not in range(128)

Please try this fix:
http://www.iredmail.org/forum/post57692.html#p57692

8

Re: error: notify_quarantined_recipients.py --force-all

Thank you for your response.

The funny thing is: I've done the ubuntu updates on 27.7. and the error was gone :-)

(Sorry for writing back so late, but I'm quite busy at the moment)

bg
Günther

9

Re: error: notify_quarantined_recipients.py --force-all

Here are the news:

Error still there. Because there where no mails quarantined the error won't occour.
So yesterday I got the error again because of 2 SPAM mails.

I looked through the notify_quarantined_recipients.py and compared it with the previous version (2.8.0) and found that there maust be a problem with the time-zone converting:

        dt = datetime.strptime(time_iso, '%Y%m%d%H%M%S')
        time_with_tz = utc_to_timezone(dt=dt, timezone=settings.LOCAL_TIMEZONE)
        time_tuple = time.strptime(time_with_tz, '%Y-%m-%d %H:%M:%S')
       

So for a quick repair I commented the lines out and changed them back to the 2.8.0 version:

        time_tuple = time.strptime(time_iso, '%Y%m%d%H%M%S')
        mail_date = time.strftime('%b %d, %Y', time_tuple)
        mail_time = time.strftime('%H:%M', time_tuple)

Tested with http://www.emailsecuritycheck.net/index.html and I got the mail ([Attention] You have 7 emails quarantined and not delivered to mailbox) and nor error at all.

Maybe this helps a little bit.

For now I am happy with this workoround.#

by
Günther

10

Re: error: notify_quarantined_recipients.py --force-all

Could you please do me a favor, write few 'print' commands in this file to print the values these 3 lines are processing?

Or, is it possible to give me direct ssh access to debug it by myself? If yes, please contact me: zhb _at_ iredmail _dot_ org

11

Re: error: notify_quarantined_recipients.py --force-all

Hi,

I've inserted some print commands:

dt = datetime.strptime(time_iso, '%Y%m%d%H%M%S')
        print "dt= ", dt
        time_with_tz = utc_to_timezone(dt=dt, timezone=settings.LOCAL_TIMEZONE)
        print "time_with_tz= ", time_with_tz
        time_tuple = time.strptime(time_with_tz, '%Y-%m-%d %H:%M:%S')
        print "time_tuple=", time_tuple

output:

root@mail:/opt/www/iredadmin/tools# python notify_quarantined_recipients.py --force-all
* 24 users are willing to receive notification email.
dt=  2017-08-13 13:45:21
time_with_tz=  2017-08-13 13:45:21
Traceback (most recent call last):
  File "notify_quarantined_recipients.py", line 303, in <module>
    time_tuple = time.strptime(time_with_tz, '%Y-%m-%d %H:%M:%S')
  File "/usr/lib/python2.7/_strptime.py", line 478, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.7/_strptime.py", line 329, in _strptime
    found = format_regex.match(data_string)
TypeError: expected string or buffer

12

Re: error: notify_quarantined_recipients.py --force-all

No idea. Is it possible to give me direct ssh access with root privilege for debugging?