stream icon indicating copy to clipboard operation
stream copied to clipboard

Log e-mail

Open lkraav opened this issue 7 years ago • 5 comments
trafficstars

Instead of additional "logging" plugins like https://github.com/No3x/wp-mail-logging/ having to be installed, is there anything stopping Stream from logging e-mail itself via a simple connector?

lkraav avatar Aug 01 '18 15:08 lkraav

@lkraav Actually, this is kinda tricky currently due to the fact that the wp_mail() only executes one action during a successfully send-off. If it's possible to get the necessary data off the PHPMailer object, given to that action, to create a meaningful log passed, then yes. It can be done.

kidunot89 avatar Jul 28 '20 16:07 kidunot89

At its core, Stream provides the ability to know when something changes and/or goes wrong, allowing for easier debugging. I personally do not feel that logging all emails is fit for the scope of this plugin, but could see the need to log when an email failed to send (because that is a problem).

kopepasah avatar Jul 30 '20 19:07 kopepasah

Stream provides the ability to know when something changes and/or goes wrong

:man_shrugging: Wrt to logging whatever info, I feel like when you have 80% of necessary infrastructure already in place, it sort of qualifies for logging whatever info.

In this case it depends more on measuring customer interest, and if it's not there at core level, it certainly might make more sense (for me) to roll this out as a separate connector plugin.

At the end of the day, the less big plugins sites run, the better (at minimum, for reducing security and performance risk surface).

lkraav avatar Jul 31 '20 10:07 lkraav

This seems to have gone stale, but I do have a consideration for this.

If we add a logging action inside Stream e.g.

add_action( 'wp_stream_custom_log', function( $data, $source_plugin ) {  // do insert log }, 10, 2 );

... then any third-party code should be able to do_action( 'wp_stream_custom_log', $data, 'my-plugin' ); to log custom data.

We would need to specify restrictions for a $data object to make it easier to validate and sanitize, but theoretically, we would be able to log all kinds of arbitrary information. The $source_plugin would be important so that we can add exclusions too.

rheinardkorf avatar Oct 13 '20 10:10 rheinardkorf

At its core, Stream provides the ability to know when something changes and/or goes wrong, allowing for easier debugging. I personally do not feel that logging all emails is fit for the scope of this plugin, but could see the need to log when an email failed to send (because that is a problem).

I would agree with you, I'm looking for solution to log any failed mail sent from the WP. This one will be helpful.

warengonzaga avatar Apr 01 '21 17:04 warengonzaga