Forum Moderators: coopster

Message Too Old, No Replies

Cron and IMAP functions

         

rfontaine

9:08 pm on Nov 30, 2005 (gmt 0)

10+ Year Member



I have a PHP script using IMAP functions that is called by a cronjob. However, the cron throws errors such as:

imap_status(): supplied argument is not a valid imap resource

The script works fine if I run it from a browser, but not from a cron job. For example,

/usr/bin/php /home/mydomain/www/cron-get-bounces.php

Have any of you run into this? And if so, did you come up with a solution?

jatar_k

10:05 pm on Nov 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



since imap_status requires 'resource imap_stream' then I am guessing the supplied resource is no good.

I am guessing that something in the environment is weird

are you sure it is the exact same script you are calling in the browser? is the script relying on session or env vars that aren't available when running it via cron.

have you tried running it via the command line? does that work?

I am also guessing there is an unhandled error farther up in your script possibly with the imap_open

rfontaine

2:10 pm on Dec 1, 2005 (gmt 0)

10+ Year Member



Thank you jatar_k, this morning I took a look at my code and discovered I forgot to use imap_open. Now it works fine.

It's the simple things that get you :-)