• Resolved Ripplestone

    (@ripplestone)


    I was using Subscribe2. After an update, the E-mails started getting sent out with no line breaks. Meaning a well formatted blog post was being jumbled up into all 1 line with no spaces between paragraphs.

    To fix this I edited the subscribe2.php code.

    The origonal piece of code looked like this:

    // remove excess white space from with $excerpt and $plaintext
    		$excerpt = preg_replace('|\s+|', ' ', $excerpt);
    		$plaintext = preg_replace('|\s+|', ' ', $plaintext);
    		// prepare mail body texts
    		$excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
    		$full_body = str_replace("{POST}", strip_tags($plaintext), $mailtext);
    		$html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
    		$html_body = str_replace("{POST}", $content, $html_body);
    		$html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
    		$html_excerpt_body = str_replace("{POST}", $html_excerpt, $html_excerpt_body);

    I changed it to this:

    // remove excess white space from with $excerpt and $plaintext
    		// $excerpt = preg_replace('|\s+|', ' ', $excerpt);
    		// $plaintext = preg_replace('|\s+|', ' ', $plaintext);
    		// prepare mail body texts
    		$excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
    		$full_body = str_replace("{POST}", strip_tags($plaintext), $mailtext);
    		$html_body = nl2br($mailtext);
    		$html_body = str_replace("{POST}", $content, $html_body);
    		$html_excerpt_body = nl2br($mailtext);
    		$html_excerpt_body = str_replace("{POST}", $html_excerpt, $html_excerpt_body);

    Hope that helps anyone who has the same problem. I spent hours looking for people talking about this, and ended up just editing the code myself.

    https://www.ads-software.com/extend/plugins/subscribe2/

Viewing 15 replies - 1 through 15 (of 22 total)
  • @ripplestone,

    Someone has reported this on here but I also cannot find it now ??

    Anyway, one fix is to comment out the lines. In the next version the lines will read:
    `$excerpt = preg_replace(‘|[ ]+|’, ‘ ‘, $excerpt);
    $plaintext = preg_replace(‘|[ ]+|’, ‘ ‘, $plaintext);’

    That should work to strip the excess white space without ruining layout. Weirdly it doesn’t do this for all users!?!

    Thread Starter Ripplestone

    (@ripplestone)

    Commenting out that codes works for “Single Posts”.
    Note i also changed:

    $html_body = str_replace("\r\n", "<br />\r\n", $mailtext);

    with

    $html_body = nl2br($mailtext);

    But it doesn’t completely fix the weekly Digest. I just got my weekly digest today (from working on this a week ago), and it’s bunched together. Same as it is reported by @belg4mit in the ilnk you sent me.

    Sounds like I should just wait for the update in the next version.

    Thank you for your attention on this.

    @ripplestone,

    There are 2 preg_replace lines in the subsribe2_cron function that creates the digest email just like those in the single post code. Change those latter instances too and you should see a difference.

    Thread Starter Ripplestone

    (@ripplestone)

    Ok. I removed those 2 lines in the subscribe2_cron function.

    Now I’ll wait a week to see if it sends out correctly.

    Thank you again for your support! I made a donation to the subscribe2 donation page. Hope you continue developing the subscribe2 further.

    Thread Starter Ripplestone

    (@ripplestone)

    I just notices there is a “Resend Digest” button in the Subscribe2 settings. I pressed that, and it sent an E-mail that looked correct! so It works now! ??

    jeanjeana

    (@jeanjeana)

    I’m still struggling with this issue, though I tried all the fixes mentioned here and on the other thread. I use Gmail and Thunderbird.

    I also tried a workaround where I put in the template where I wanted newlines, and replaced every mention of strip_tags($somestring) with strip_tags($somestring, '<p><a>'). The messages are now readable but unfortunately, I still lose all my links.

    Could the have anything to do with the headers? Notice that back when messages were working under 7.0.1, headers used have

    Content-Type: text/plain;

    Now the headers are

    Content-Type: text/html;

    Since I just want to send text excerpts, I tried commenting out references to the html content-type but it didn’t work. Just thrashing around right now but I guess my subscribers can live without clickable links for a while.

    //if ( $type == 'html' ) {
    // To send HTML mail, the Content-Type header must be set
    //	$header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
    //		} else {
    $header['Content-Type'] = "text/plain; charset=\"".get_option('blog_charset') . "\"";
    //		}</a>

    @jeanjeana,

    If your emails are coming as text/html either you have opted to get HTML notifications in Subscribe2->Your Subscriptions or you have bought Subscribe2 HTML.

    If it’s the former visits Subscribe2->Your Subscriptions and change back to plain text notifications.

    If it’s the latter, revert to the original code and post for help on the WPPlugins.com forum.

    jeanjeana

    (@jeanjeana)

    Thanks–

    I only have the regular version of Subscribe2. I clearly checked off plain text excerpts at the bottom of settings, and the first thing I did was try different options to see if that would fix it. Is there another setting that I’m missing?

    After the adjustments I made, the email looks okay (including urls) as long as I configure my mail program to view it as plain text. However my subscribers will probably not know how to do this.

    @jeanjeana,

    I clearly checked off plain text excerpts at the bottom of settings

    But that secretion is what happens to new users who register with your site if it’s in the AutoSubscribe section.

    As I said above, your personal setting is at Subscribe2->Your Subscriptions.

    jeanjeana

    (@jeanjeana)

    Hmm, I can’t see any option to set personal settings to HTML or otherwise in Subscribe2->Your Subscriptions. I see only:

    Receive periodic summaries of new posts?: Yes No
    Do not send notifications for post made by these authors:

    ??

    @jeanjeana,

    It seems as though you are sending emails on a periodic basis in a digest format them.

    I have no idea how you’ve managed to get the code sending in HTML format for this type of email. I’d suggest you revert to the original code and then apply this fix:

    Replace 4 instances of:
    preg_replace('|\s+|'
    With:
    preg_replace('|[ ]+|'

    Yep @mattyrob – that last fix took care of it on my weekly digests.

    @mattyrob,

    Thank you for your reponse.

    I uninstalled and reinstalled 7.2 and made the replacements you suggested. It didn’t work (and I tried it twice), so I am going to roll back to 7.0.1, which did work for me. I am using WP 3.2.1 and Arthemia, by the way. The problems I have been having since the reinstall are identical to the problems I had before the reinstall.

    I’ll post back the results of rolling back.

    I am having the same issue. I discovered that the
    <pre> tag disapeared from the emails. The emails that show newlines correctly have <pre> tag:

    <div id="messagebody"><div class="message-part">
    <pre>Blog ...</pre>

    Recently, all emails look like this:

    <div id="messagebody"><div class="message-htmlpart">
    <!-- html ignored --><!-- head ignored -->
    <!-- meta ignored --><div class="rcmBody"><p>Blog ...

    Don’t know why it changed suddenly. Upgrading to the latest didn’t help either.

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘[Plugin: Subscribe2] emails have no line breaks. how to add them’ is closed to new replies.