liuch / dmarc-srg

A php parser, viewer and summary report generator for incoming DMARC reports.
GNU General Public License v3.0
218 stars 32 forks source link

How IMAP reports are reading #25

Open nasirmgcc opened 2 years ago

nasirmgcc commented 2 years ago

Hi, Can you tell me how the imap will take automatically reports from the " Mailbox " and post into database, i have to run some Cronjobs or what is the procedure to run " util/fetch_reports.php "

liuch commented 2 years ago

Hi, If you want to get reports automatically, you have to use cron on your server. Currently, you can automatically take reports from your mailboxes or directories on the server. See comments in utils/fetch_reports.php for details.

Here is my cron rule:

0 */6 * * * www-data cd /usr/local/share/dmarc-srg/www && php utils/fetch_reports.php > /dev/null

It gets reports from the all configured sources 4 times a day (every 6 hour).

nasirmgcc commented 2 years ago

Thank you for reply

This will work on the Shared Server like JustHost ? with Cron job?

liuch commented 2 years ago

Why not? I don't use JustHost, but it definitely works on the cheapest droplet of DigitalOcean. The main thing is that there must be access to cron and php. The hoster may also block some mail ports to avoid using the service by spammers, but this is usually solved by emailing the support, and these are unlikely to be imap ports.

liuch commented 1 year ago

From #31. To know what you're failing, I need to know what exactly you're trying to do. How did you add a job for cron. What exact command did you execute? What files did you edit for this? And of course, in my example, the command is specified with paths that you may not have. Consider this.

nasirmgcc commented 1 year ago

@liuch i used as

www-data cd /home4/nasirryk/public_html/dmarc.xpertsgroup.net && /usr/local/bin/php utils/fetch_reports.php > /dev/null

liuch commented 1 year ago
  1. Does this command work in console: cd /home4/nasirryk/public_html/dmarc.xpertsgroup.net && /usr/local/bin/php utils/fetch_reports.php
  2. Do you have a user www-data on your server?
  3. Does the command above work under user www-data?
  4. How exactly did you add that command in the cron list?

My first example is not a command but a line in one of the OS config files.

nasirmgcc commented 1 year ago

my username is " nasirryk "

liuch commented 1 year ago

In the cron job, you need to specify a user under which you are going to run the script. This is usually the system user under which your web server is running, it is usually www-data. I highly recommend that you figure out how to run commands on your OS on a schedule. In the previous post, I indicated which command to execute in order to get incoming reports. I personally use cron. How you set it up is up to you.

nasirmgcc commented 1 year ago

is it possible to run the CRON job without " user " to run commands, can we create the URL to execute will be more easy to manage.

Shnoulle commented 1 year ago

is it possible to run the CRON job without " user " to run commands,

No …

can we create the URL to execute will be more easy to manage.

then action is done as www-data user … (and about an url to call : need some security check)

liuch commented 1 year ago

You can use the nobody user in your /etc/crontab and run your own script there, but... why? Running commands from a URL can cause security issues. If you started looking for ways to bypass the OS security mechanisms, most likely you are doing something wrong.

nasirmgcc commented 1 year ago

I am looking to execute CRONJob by access simple page like : https://dmarc.mysite.com/import-mails.cronjob.php because on shared server difficult to run commands