If I retrieve the mail manually, mailhandler works....cron is running successfully, but it isn't triggering mailhandler to go get the mail. What can be done?

CommentFileSizeAuthor
#2 mailhandler_cron_fix.patch1.69 KBneochief

Comments

geodaniel’s picture

It sounds like there might be a module running in cron before mailhandler, which either takes up more time than it should or drops out once it's done. What other modules do you have running on cron?

neochief’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.69 KB

Cron doesn't works, because mailhandlers opens imap session two times. Here's a fix.

BetaTheta’s picture

I tried using that patch, it didn't seem to help.

BetaTheta’s picture

Correction, it seems mailhandler works when I run cron manually, but not when it runs automatically. When I look at the logs, it seems the manually runs are done by me while the automatic ones are done by anonymous. Could this be the issue?

pacome’s picture

Status: Active » Needs review

I also have this problem : when I test the connection with the mailbox, and if i retrieve manualy the mails, it works perfectly (for both POP and IMAP).

But when i run a cron (both automaticaly or manualy) I get this for POP :

    * warning: imap_open() [function.imap-open]: Couldn't open stream {mail.xxxx.be:110/pop3/novalidate-cert/notls}INBOX in /home/xxxx/domains/xxx.be/public_html/xxxxx/sites/all/modules/mailhandler/mailhandler.module on line 193.
    * warning: imap_close(): supplied argument is not a valid imap resource in /home/xxxxx/domains/xxxx.be/public_html/xxxxx/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 625.

And this for IMAP :

    * warning: imap_header() [function.imap-header]: Bad message number in /home/xxx/domains/xxx.be/public_html/xxxxxxx/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 636.
    * warning: imap_fetchstructure() [function.imap-fetchstructure]: Bad message number in /home/xxx/domains/xxxx.be/public_html/xxxxx/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 60.
    * warning: imap_fetchstructure() [function.imap-fetchstructure]: Bad message number in /home/xxxx/domains/xxxx.be/public_html/xxxxxx/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 60.
    * warning: imap_fetchstructure() [function.imap-fetchstructure]: Bad message number in /home/xxxx/domains/xxxx.be/public_html/xxxx/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 121.
    * warning: imap_close(): 75 is not a valid imap resource in /home/xxxx/domains/xxxx.be/public_html/xxxx/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 752.

And not a single mail is retrieved...

Any idea ?

mailhandler 6x-1.x-dev

-P-

pacome’s picture

Status: Needs review » Active
pacome’s picture

Status: Needs review » Active

Bump !
Does anyone could give a hand on that problem ?

I can connect to the mail box
I can retrieve mails manualy
but Cron doesn't do the job...

Logs says :
one time per cron : Could not fetch structure for message number 11
and two times per cron : imap_close(): 74 is not a valid imap resource in /home/.../sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 684.

I spent hours on different try out with no success... and I still have no idea what goes wrong..
I would really appreciate any advice.

neochief’s picture

did you tried my patch?

pacome’s picture

Yep ! It works !

I first tried to patch mailhandler.module file, and had no results
I realised the file to patch was mailhandler.retrieve.inc... Ooops !

Thanks !!
Sorry for not looking more carefully ;)
-P-

neochief’s picture

Status: Active » Reviewed & tested by the community

so, setting issue to RTBC

Ian Ward’s picture

Marked http://drupal.org/node/595314 as duplicate. I applied a patch very similar to #2 by @neochief. The difference being to only proceed if there are actually new messages. I believe the problem like neochief states, and more specifically, there are problems w/ certains stacks (php/os's) when one imap session is opened before a previous is closed. Now, session is opened, closed, then opened again. This is not most efficient and may refactor later. I've commited this, and can be further tested on the 6.1 dev branch. I'll leave open until more positive feedback.

jgraham’s picture

I can confirm that on 6.x-1.8, I was experiencing the bug as described here.

Upgrading to 6.x-1.x-dev (Dec 5th) solved the problem.

Thanks all!

edit: Since the ticket title does not describe exactly what I was experiencing, but other comments detailed the same issue, I wanted to clarify that I was receiving the following error during cron, but manual execution worked fine:

imap_open() [<a href='function.imap-open'>function.imap-open</a>]: Couldn't open stream {EXAMPLE.com:110/pop3}INBOX in /var/www/html/sites/all/modules/mailhandler/mailhandler.module on line 193.
imap_close(): supplied argument is not a valid imap resource in /var/www/html/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 650.
Ian Ward’s picture

@jgraham I am glad it is working for you now. Could you let me know what operating system and php version you are using? Thanks

jgraham’s picture

@Ian Ward: Fedora 10, PHP 5.2.9

jgraham’s picture

Just wanted to add that if two cron instances run at the same time this issue may show up again.

I don't think anything can be done by mailhandler about that scenario though.

jlv’s picture

We had a very similar problem. We ran through supercron and confirmed mailhandler was the issue. Upgrading to 6.x-1.x-dev (Dec 5th) solved the problem for us too.

Ian Ward’s picture

Status: Reviewed & tested by the community » Fixed

This has been fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sgtsaughter’s picture

Component: User interface » Mailhandler

Anyone know how to apply this patch with git? I am getting a fatal: unrecognized input when I run git apply --index mailhandler_cron_fix.patch

EDIT: I am getting a HUNK FAILED error when trying to apply this patch. Is there a way I can get this patch for the 6x 1.11 branch?