Jump to content

RockMailLogger - log all sent E-Mails to PW log


bernhard
 Share

Recommended Posts

This module will log information about all mails that are sent via WireMail to the PW logs

img

From PW Weekly:

Quote

New module: WireMail Mail Logger by Bernhard Baumrock

WireMail Mail Logger, also known as RockMailLogger, is a new module released just this week by Bernhard Baumrock. In a nutshell this module adds an entry to a ProcessWire log file for each message sent using WireMail.

The mail logging feature provided by this module can be quite helpful while debugging email related issues, but also if you just want to check what kind of messages your site is actually sending out. WireMail Mail Logger is also really easy to get started with: just install it and you're good to go. Log entries can be viewed via ProcessWire's log viewer.

Keep in mind, though, that since the message itself will indeed be logged, you probably don't want to enable this module on a production site in case you're sending messages that shouldn't be fully readable by superusers.

You can install this module via the built-in module installer, or – in case you prefer the manual installation method – you can grab the code from the RockMailLogger GitHub repository. If you have any questions or require support, head down to the dedicated support forum thread.

Thanks to Bernhard for sharing this module with us!

https://github.com/BernhardBaumrock/RockMailLogger

https://modules.processwire.com/modules/rock-mail-logger/

  • Like 9
  • Thanks 1
Link to comment
Share on other sites

  • 3 years later...

I have a couple of log modules installed. rockmaillogger is the only one that triggers a 504 Gateway Timeout

Is that server specific? Something quota issue? Too much data? Or is it a bug?

(As a comparison, I also have a Promailer-email log module that estimates 1629756 entries and shows the first page (1-100 entries) alright. However, that one doesn't let me move on to page 2 and further.)

 

Link to comment
Share on other sites

Hi @fruid I don't think that my module causes this as I'm simply using PW's logging features. You can try renaming the log to something different and using it with a subset of the real data. Then copy over junk for junk and see if/when the error starts to occur. Not sure if that's the right thing to do with 504 errors but that could bring more insights.

Link to comment
Share on other sites

I read your message as "thank you for your help". You are welcome.

14 minutes ago, fruid said:

no wonder. what's a better practice?

A better practice than sending massive amounts of spam emails and logging all of them without cleaning up the logs from time to time? Sending only necessary mails. And cleaning up the logs ?? 

Or a better practice than complaining about free and open source modules? Helping to debug things and then trying to add improvements and creating a PR ?  You could for example add the option to cleanup the mail log automatically after x days or after y logged mails...

Link to comment
Share on other sites

apologies, didn't mean to be rude, I'm not complaining at all, contrary to your impressions. Thanks a lot for your help and the module works perfectly! Caught a lot of emails that went nowhere. 

I need to figure out a way to clean up the logs, maybe with a lazycron? or maybe split it up in more files so I don't have to handle huge files at some point. Also, maybe there's a way to access the very log folder of a web server via PW? like /var/log/

  • Like 1
Link to comment
Share on other sites

Thx @fruid for the clarification. First of all how many emails did you send to get a 10GB logfile?? The logger logs quite a lot (headers etc) but I thought better to have than to miss it.

I think the easiest way to do the cleanup would be to do the cleanup whenever a new log entry is created. That should be really easy to do using https://processwire.com/api/ref/wire-log/prune/

So you could add a config setting to the module that holds the maximum number of days the log should be kept and everything should work fine. This might also be a good idea regarding gdpr or similar regulations.

5 minutes ago, fruid said:

Also, maybe there's a way to access the very log folder of a web server via PW? like /var/log/

That only depends on your server setup. You could also create PHP scripts that have root access to your server. It only depends on the permissions you give to PHP (for example to use exec()) and to the user that runs the script.

  • Like 1
Link to comment
Share on other sites

Hey @fruid have just been working on logs on another module. This is how you can prune the logs to a given number of bytes:

    $this->wire->log
      ->getFilelog("rock-mail-logger")
      ->pruneBytes(2000);

This will prune the log to 2000 bytes (which is obviously very little just for testing).

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...