Search code examples
phpcronimap

How to read email using PHP's imap function and cronjob


I have a PHP script which used for reading the emails and then insert details into database. When I run this script from browser it works perfect but when I tried to run this script using Linux cronjob at specified time then it failed.

Note: I already know how to use cron. My other scripts runs perfectly except this one.


Solution

  • I solved the issue by using the curl.

    I create a cronjob which call my script with its actual URL like below and it works perfectly for me:

    17 16 * * * /usr/bin/curl https://your_script_url