Cron job - no results

This plugin allows you to report an issue in MantisBT by sending an email to a particular mail account

Moderators: Developer, Contributor

Post Reply
polityk
Posts: 4
Joined: 21 Nov 2016, 07:46

Cron job - no results

Post by polityk »

Hi, first of all great work with EmailReporting, it is an awsome addition to Mantis!
I am a new Mantis & EmailReporting user but not so new to linux/bsd and system administration so i have some degree of knowledge of what i am doing ;)

My setup is:
- FAMP server on FreeBSD 10.3
- Mantis 1.2.19
- EmailReporting 0.9.3-DEV
- some customisation done to Mantis and some plugins enabled
- EmailReporting uses one IMAP account with Exchange server, tested and works ok

I have created a script:

Code: Select all

# !/bin/bash
/usr/local/bin/php /usr/local/www/mantis/plugins/EmailReporting/scripts/bug_report_mail.php
and added in CRONTAB:

Code: Select all

* * * * * root /usr/local/bin/mantisemailreport.sh > /var/log/mantis-emailreport.log
Crontab runs this script and i get the result in log.
The result in 99% of time looks like this:

Code: Select all

Start checking all mailboxes: Monday 21st of November 2016 09:55:00

array(14) {
  ["enabled"]=>
  int(1)
  ["description"]=>
  string(27) "ticket@mydomain.com - IMAP"
  ["mailbox_type"]=>
  string(4) "IMAP"
  ["hostname"]=>
  string(12) "<server_ip>"
  ["port"]=>
  int(143)
  ["encryption"]=>
  string(8) "STARTTLS"
  ["ssl_cert_verify"]=>
  int(0)
  ["erp_username"]=>
  string(17) "ticket@mydomain"
  ["erp_password"]=>
  string(12) "xxxxxxxxxxxx"
  ["auth_method"]=>
  string(4) "USER"
  ["project_id"]=>
  int(22)
  ["global_category_id"]=>
  int(1)
  ["imap_basefolder"]=>
  string(0) ""
  ["imap_createfolderstructure"]=>
  int(1)
}

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Retrieve list of messages
[pear_error: message="NO, The specified message set is invalid." code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Mailbox: ticket@mydomain.com - IMAP
Location: Create IMAP folder
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]



Done checking all mailboxes
So no new messages - agreed.
When i send an email, it lands in a proper project folder, the checking result is always the same as above.
I had literally 2 or 3 times when it detected the email.
To make things funnier when i click in plugin management "bug_report_mail.php" or "plugin.php?page=EmailReporting/bug_report_mail" link it detects emails every time with no problems.

I am fighting this for a few days now, checked permissions, ownership, communication, tried running wget or lynx in shell with the link as a parameter and it still did not work. Somehow invoking this by the server itself does not detect emails in folders despite running the script properly.
Setting for blocking this script in browser is "NO", but tried also turning it "YES" and this does not effect things.
I hope you guys could have any ideas ?

Best Regards,
Gregory
Last edited by polityk on 23 Nov 2016, 09:06, edited 1 time in total.
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

IMAP and Exchange have always been at odds with each other in EmailReporting.
I was hoping all issues were resolved.

Based on some googling it appears this error might be returned when there are no messages in a folder "NO, The specified message set is invalid."
Some also say that some commands need to be reversed

The other error might be because it tries to create a folder that already exists...

Which version of Microsoft Exchange are you using?
Which version of PHP are you running?
Based on that your saying that from the webserver everything works properly and only through the commandline you have issues.... could it be that a firewall is messing with the PHP process?
polityk
Posts: 4
Joined: 21 Nov 2016, 07:46

Re: Cron job - no results

Post by polityk »

Thanks for the reply.

Regarding those errors, i think that they might be omitted, as from web it seems to work as a charm with the same errors.
All folders were created properly and there are as many errors as folders.
Theese errors appear to show up when there are no messages in a folder.

- PHP 5.6.25
- exchange 2013

You are correct, the issue is connected with running script in commandline.
Maybe runnig the script from localhost has something to do ?
There is no firewall in place, exchange and mantis are on the same network.
The strangest thing is that yesterday it worked a few times and then stopped again, no changes made to the server.
I just came back to work after weekend, wanted to get back to the problem and magically the script detected messages.
I will try to look for something in the exchange logs, maybe frequent running has something to do....
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

maybe but you would expect that it would break when it tries to connect, not further on into the process if that is the case

Those errors ("NO, The specified message set is invalid.") might only be there if there no messages in the folder which would mean that they don't matter as when there are messages in the folder they would be processed normally

The other error has to do with IMAP folder creation. If this happens it obviously has not entered the folder and processed anything in it. I'll try to add some extra error handling to debug this better
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

Could you please download the latest version github and see what the errors say now

I made a small change that will atleast tell us the foldernames that are having problems
https://github.com/mantisbt-plugins/Ema ... dbb63fca42
polityk
Posts: 4
Joined: 21 Nov 2016, 07:46

Re: Cron job - no results

Post by polityk »

Downloaded, tested.

I have sent you a PM with results as the folder names fall unde NDA.

I will edit this post later and put our findings here.
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

hmmm not all of the folders give an error, just some of them. Are it always the same folders that produce errors?

I'm going to try to reproduce this issue on Exchange 2010 and PHP 5.6.x
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

Alright issue has been reproduced.

So i will be working on fixing this
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

I think i more or less found the issue. This is just my theoretical assessment. so not officially verified whether its really true

Exchange is not happy with errors being produced. It allows a max of 10 errors before the connection is more or less dropped/ignored
So those "NO, The specified message set is invalid." errors are produced because of empty folders where Exchange refuses to return an empty message set and instead returns an error.
After getting that error 10 times other valid commands that worked before also start producing errors

So those "Create IMAP folder" errors can be ignored as the cause is because of this error "NO, The specified message set is invalid.". Now i need to find a way to check whether a folder has messages without producing an error when there are no messages

The moment when everything worked for you was when enough other folders had messages so that "NO, The specified message set is invalid." was not generated 10 times
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Cron job - no results

Post by SL-Gundam »

Hopefully this fixes this specific issue
https://github.com/mantisbt-plugins/Ema ... 0ce17dc3f6

Keep in mind that if you encounter any other errors generated by the mail server and the number of errors are more then 10 we will see this issue again

Let me know whether this works for you
polityk
Posts: 4
Joined: 21 Nov 2016, 07:46

Re: Cron job - no results

Post by polityk »

Thank you for the awsome work!

For now it looks like there are no problems, all errors are gone and the messages are read.

After some more testing all the problems are gone, messages are read properly.
It looks like indeed it was what SL-Gundam discovered and his fix made an immediate effect.
Thank again for the great work!
Post Reply