• byarts

    (@byarts)


    Plugin 10.22.1
    We are sending out a plain text excerpt. Looking at the source of the email it contains:
    Content-Type: text/html; charset=UTF-8
    This breaks the text formatting.
    When sending a Preview email within the admin panel:
    Content-Type: text/plain;
    is sent correctly.

    Thank you,
    -Rob B.

Viewing 8 replies - 1 through 8 (of 8 total)
  • @byarts

    Is this happening for digest or per post emails? And is it specific to Public or Registered Subscribers?

    Thread Starter byarts

    (@byarts)

    The text/html is showing up in the per post emails, to Public Subscribers.
    Thank you very much for your reply.
    -Rob B.

    @byarts

    I had a review of the code and can’t see how that might be happening but I’ll test more fully later and get back to you.

    @byarts

    I’ve just tested this and I’m not seeing this issue on my test install. Have you tried with other plugins disabled?

    jakobvase

    (@jakobvase)

    @mattyrob

    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 7 years ago by jakobvase.

    @jakobvase

    That filter only hets added if the plugin is sending an ‘html’ email type and when sending plain text email that part of the code isn’t called.

    Unless there is some problem in the destruction and construction again of the $phpmailer instance I cannot see how that would be an issue.

    What version of WordPress and PHP are you using on your site?

    jakobvase

    (@jakobvase)

    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

    @jakobvase

    I’m testing on PHP7 so perhasp that’s why I’m not seeing the issue. It’s all to do with how class objects are constructed and deconstructed I suspect.

    Anyway, I’ll try to create and submit a patch for future release.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Public Subscribers Email – Content-Type:’ is closed to new replies.