Search code examples
phpphpmailercronattachment

sending data with attachment doesn't work Cronjob


I dont know alot about cron job but i have a php file which sending data with attachment when i run it using the browser it's working fine and attachment is sent ,but if i use cron job to run it ,it never goes with the attachment. here is the cron job command-line :

/opt/php54/bin/php /home/username/public_html/path/to/myscript.php

and here is the place of error in the php file ,as the cron job sending me email with "Some how file :hhshd.jpg is not exist!" , however the data with attachment is sent successfully when i use the browser.

 if (!file_exists("uploads/" .  $fileName))
            {
                die("Some how file :$fileName is not exist!");
            } 

Note: i am using the cronjob of Hostgator.


Solution

  • Problem solved i have used this cron job command:

    curl http://yoursite/path/to/publish.php