Last active
October 16, 2018 11:14
-
-
Save frugan-dev/6c4d22cd856456480bd77b988b5c9e80 to your computer and use it in GitHub Desktop.
Wordpress action for multipart email with wp_mail function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"soundasleep/html2text": "~0.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
add_action( 'phpmailer_init', 'phpmailer_init' ); | |
//http://wordpress.stackexchange.com/a/191974 | |
//http://stackoverflow.com/a/2564472 | |
function phpmailer_init( $phpmailer ) | |
{ | |
if( $phpmailer->ContentType == 'text/html' ) { | |
$phpmailer->AltBody = Html2Text\Html2Text::convert( $phpmailer->Body ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please see this gist: https://gist.github.com/youri--/c4618740b7c50c549314eaebc9f78661
It describes and fixes a huge problem when sending consecutive mails.
A simplified fix follows: