jakobvase
Forum Replies Created
-
Hi @mattyrob
At the end of the publish function, each of the groups of subscribers get mails sent to them:
// Registered Subscribers first // first we send plaintext summary emails $recipients = $this->get_registered( "cats=$post_cats_string&format=excerpt&author=$post->post_author" ); $recipients = apply_filters( 's2_send_plain_excerpt_subscribers', $recipients, $post->ID ); $this->mail( $recipients, $subject, $plain_excerpt_body ); // next we send plaintext full content emails $recipients = $this->get_registered( "cats=$post_cats_string&format=post&author=$post->post_author" ); $recipients = apply_filters( 's2_send_plain_fullcontent_subscribers', $recipients, $post->ID ); $this->mail( $recipients, $subject, $plain_body ); // next we send html excerpt content emails $recipients = $this->get_registered( "cats=$post_cats_string&format=html_excerpt&author=$post->post_author" ); $recipients = apply_filters( 's2_send_html_excerpt_subscribers', $recipients, $post->ID ); $this->mail( $recipients, $subject, $html_excerpt_body, 'html' ); // next we send html full content emails $recipients = $this->get_registered( "cats=$post_cats_string&format=html&author=$post->post_author" ); $recipients = apply_filters( 's2_send_html_fullcontent_subscribers', $recipients, $post->ID ); $this->mail( $recipients, $subject, $html_body, 'html' ); // and finally we send to Public Subscribers $recipients = apply_filters( 's2_send_public_subscribers', $public, $post->ID ); $this->mail( $recipients, $subject, $plain_excerpt_body, 'text' );Since the html mails are sent to registered subscribers, before the plain text mails are sent to the public subscribers, the filter is added and not removed.
The problem occurs if someone registers for html mails, and then someone registers for the public mails. In that case, the html email will be sent first, and the plain text email afterwards, in the same context – so the filter is still present when the plain text email is sent.
WordPress 4.8.3, PHP 5.6.31
Hi, I have the same issue and browsed through your source.
I believe the issue may be in class-s2-core, in ‘mail’ you set a filter:
if ( 'html' === $type ) { $headers = $this->headers( 'html' ); add_filter( 'wp_mail_content_type', array( $this, 'html_email' ) );but you never remove this filter. The ‘html_email’ function sets the content-type to text/html in all cases. And since all the html emails are sent first, the plain text emails are all set to html.
I removed the ‘add_filter’ line quoted above, and it fixed the issue (though I haven’t tested whether it works for html emails. It should work though – I don’t think you need the filter at all.)
Will you fix it?
- This reply was modified 8 years, 4 months ago by jakobvase.