[Plugin: BuddyPress Group Email Subscription] Emails generated with bare LF in message body, causing
-
The plugin generates non-compliant emails containing bare LFs in the message body which, when installed on server with an outgoing SMTP that does not convert bare LFs to CRLF (e.g. Windows Server using IIS6 SMTP) will cause some receiving email servers to reject the messages.
Currently using the following wp_mail hook to detect and fix (for any outgoing email which has the same issue) rather than modify the plugin code, but should ideally be fixed in the plugin.
Note: comment lines can be uncommented to debug to a log file.
function ks_fix_bare_lf_in_mail($vars) { $message = $vars['message']; if (!is_null_or_empty_string($message) && preg_match("/^(?=\n)|[^\r](?=\n)/", $message) > 0) { ////Commented lines for debug only //error_log('Bare LF found in message:'); //error_log(preg_replace("/^(?=\n)|[^\r](?=\n)/", "\[BARE LF]", $message)); $message = preg_replace("/^(?=\n)|[^\r](?=\n)/", "\\r", $message); // regex from https://www.mantisbt.org/bugs/view.php?id=6749 $vars['message'] = $message; //if (preg_match("/^(?=\n)|[^\r](?=\n)/", $message) > 0) // error_log('Bare LFs still exist!'); //else // error_log('Bare LFs fixed.'); } return $vars; } add_filter('wp_mail', 'ks_fix_bare_lf_in_mail'); // Tests whether string is present and neither empty nor only white space function is_null_or_empty_string($string){ return (!isset($string) || trim($string)===''); }
https://www.ads-software.com/extend/plugins/buddypress-group-email-subscription/
- The topic ‘[Plugin: BuddyPress Group Email Subscription] Emails generated with bare LF in message body, causing’ is closed to new replies.