New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange logs when using Mail Bank SMTP plugin #64

Closed
MikiLegenda opened this Issue Sep 3, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@MikiLegenda

MikiLegenda commented Sep 3, 2017

When Mail Bank SMTP plugin is activated, WP Mail Logging plugin is showing strange logs with both Receiver, Subject and Header showing letter "w". You cannot click on the log.

See attachment:

screen shot 2017-09-03 at 22 59 15

@No3x

This comment has been minimized.

Show comment
Hide comment
@No3x

No3x Sep 3, 2017

Owner

Do you know what should be logged actually? I can't reproduce this without knowing what is sent.

Owner

No3x commented Sep 3, 2017

Do you know what should be logged actually? I can't reproduce this without knowing what is sent.

@MikiLegenda

This comment has been minimized.

Show comment
Hide comment
@MikiLegenda

MikiLegenda Sep 3, 2017

Actually nothing is being sent out in the background. Only these strange logs keep building up. When you actually do send a test email for example, it does log it.

This only happens if you install and activate Mail Bank SMTP plugin. I noticed this when I wanted to double check if Mail Bank SMTP plugin is working properly.

When I deactivate Mail Bank SMTP plugin, strange logs stop.

MikiLegenda commented Sep 3, 2017

Actually nothing is being sent out in the background. Only these strange logs keep building up. When you actually do send a test email for example, it does log it.

This only happens if you install and activate Mail Bank SMTP plugin. I noticed this when I wanted to double check if Mail Bank SMTP plugin is working properly.

When I deactivate Mail Bank SMTP plugin, strange logs stop.

@No3x

This comment has been minimized.

Show comment
Hide comment
@No3x

No3x Sep 3, 2017

Owner

I was able to reproduce the error. When activating the plugin WP Mail SMTP Plugin by Mail Bank the trouble starts:

Warning: Illegal string offset 'to' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 228 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Illegal string offset 'subject' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 229 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Illegal string offset 'headers' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 231 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Illegal string offset 'attachments' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 232 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Cannot modify header information - headers already sent by (output started at /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:231) in /home/ubuntu/workspace/wp-includes/pluggable.php on line 1174 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.1608 7873368 3. do_action() /home/ubuntu/workspace/wp-admin/admin.php:154 0.1636 7990432 4. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1636 7990512 5. wp_mail_bank_redirect() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1682 7989880 6. wp_redirect() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:685 0.1683 7999320 7. header() /home/ubuntu/workspace/wp-includes/pluggable.php:1174

This is caused by the code in WP Mail SMTP Plugin by Mail Bank:

      $meta_data_array = array();
      foreach ($meta_values as $value) {
         $unserialize_data = maybe_unserialize($value->meta_value);
         array_push($meta_data_array, $unserialize_data);
      }
      mailer_file_for_mail_bank();
      if ($meta_data_array[0]["mailer_type"] == "php_mail_function") {
         add_action("phpmailer_init", "email_configuration_mail_bank");
      } else {
         apply_filters("wp_mail", "wp_mail");
      }
      oauth_handling_mail_bank();

Notice the apply_filters("wp_mail", "wp_mail");
This passes a string to the logging method of WP Mail Logging.
The 'w' is produced by the first letter of "wp_mail" because the string is incorrectly processed as associative array.

The WordPress Codex about wp mail states about the parameters:

$args
(array) (required) A compacted array of wp_mail() arguments, including the "to" email, subject, message, headers, and attachments values.
Default: array()

Hence passing a string "wp_mail" as argument contravenes the filter/hook contract.
It is not clear to me why they want to call to filter/hook with "wp_mail" argument.

So:

  1. WP Mail Logging fulfills the filter/hook contract. To make it more robust it should only try to log if the parameter is an array
  2. The doubtful apply_filters("wp_mail", "wp_mail"); should be reviewed/explained by WP Mail SMTP Plugin by Mail Bank
Owner

No3x commented Sep 3, 2017

I was able to reproduce the error. When activating the plugin WP Mail SMTP Plugin by Mail Bank the trouble starts:

Warning: Illegal string offset 'to' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 228 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Illegal string offset 'subject' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 229 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Illegal string offset 'headers' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 231 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Illegal string offset 'attachments' in /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php on line 232 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.0003 244248 3. require_once('/home/ubuntu/workspace/wp-load.php') /home/ubuntu/workspace/wp-admin/admin.php:31 0.0003 245008 4. require_once('/home/ubuntu/workspace/wp-config.php') /home/ubuntu/workspace/wp-load.php:39 0.0004 252728 5. require_once('/home/ubuntu/workspace/wp-settings.php') /home/ubuntu/workspace/wp-config.php:92 0.1122 7159264 6. do_action() /home/ubuntu/workspace/wp-settings.php:411 0.1257 7297272 7. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1257 7297424 8. user_functions_for_mail_bank() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1262 7303576 9. apply_filters() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:499 0.1262 7305128 10. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:235}() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305272 11. No3x\WPML\WPML_Plugin->log_email() /home/ubuntu/workspace/wp-includes/plugin.php:235 0.1262 7305512 12. No3x\WPML\WPML_Plugin->extractFields() /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:253 Warning: Cannot modify header information - headers already sent by (output started at /home/ubuntu/workspace/wp-content/plugins/wp-mail-logging/WPML_Plugin.php:231) in /home/ubuntu/workspace/wp-includes/pluggable.php on line 1174 Call Stack: 0.0002 242144 1. {main}() /home/ubuntu/workspace/wp-admin/plugins.php:0 0.0002 243448 2. require_once('/home/ubuntu/workspace/wp-admin/admin.php') /home/ubuntu/workspace/wp-admin/plugins.php:10 0.1608 7873368 3. do_action() /home/ubuntu/workspace/wp-admin/admin.php:154 0.1636 7990432 4. call_user_func_array:{/home/ubuntu/workspace/wp-includes/plugin.php:524}() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1636 7990512 5. wp_mail_bank_redirect() /home/ubuntu/workspace/wp-includes/plugin.php:524 0.1682 7989880 6. wp_redirect() /home/ubuntu/workspace/wp-content/plugins/wp-mail-bank/wp-mail-bank.php:685 0.1683 7999320 7. header() /home/ubuntu/workspace/wp-includes/pluggable.php:1174

This is caused by the code in WP Mail SMTP Plugin by Mail Bank:

      $meta_data_array = array();
      foreach ($meta_values as $value) {
         $unserialize_data = maybe_unserialize($value->meta_value);
         array_push($meta_data_array, $unserialize_data);
      }
      mailer_file_for_mail_bank();
      if ($meta_data_array[0]["mailer_type"] == "php_mail_function") {
         add_action("phpmailer_init", "email_configuration_mail_bank");
      } else {
         apply_filters("wp_mail", "wp_mail");
      }
      oauth_handling_mail_bank();

Notice the apply_filters("wp_mail", "wp_mail");
This passes a string to the logging method of WP Mail Logging.
The 'w' is produced by the first letter of "wp_mail" because the string is incorrectly processed as associative array.

The WordPress Codex about wp mail states about the parameters:

$args
(array) (required) A compacted array of wp_mail() arguments, including the "to" email, subject, message, headers, and attachments values.
Default: array()

Hence passing a string "wp_mail" as argument contravenes the filter/hook contract.
It is not clear to me why they want to call to filter/hook with "wp_mail" argument.

So:

  1. WP Mail Logging fulfills the filter/hook contract. To make it more robust it should only try to log if the parameter is an array
  2. The doubtful apply_filters("wp_mail", "wp_mail"); should be reviewed/explained by WP Mail SMTP Plugin by Mail Bank

@No3x No3x closed this Oct 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment