Kimler Sidebar Menu

Kimler Adventure Pages: Journal Entries

search cloudRandom Searches
random top 40

Posting via Email - Unwanted Line Breaks

Filed in:b2evo

Posting via Email - Unwanted Line Breaks

May 20th, 2005  · stk

I received the following message in today's mail:

Hi, [your "blogging by email" tutorial is a] great addition to the b2e-site! It helped me a lot. I have one question with which maybe you could help me. When posting a message through email, the lines are broken off, which results in a bad layout of the message (see it at Any idea how to solve this? I tried adding a paragraph class but this did not solve it. Thanks in advance.

To be quite honest, though I put up the tutorial about blogging via email, it's not a feature that I use much (aside from tests, like this one). And those tests are mainly to see if the email connection is working and so are short, in length. So ... I'm putting up this longer one, to see how my email client(s) handles long entries, to see if I too, get ugly line breaks. EDIT: I did and I fixed it ... the fix is below ...

I am using HTML in this email-by-blog entry; things like "<p>" and "<blockquote>", just as I would if I were making a post in the back office.

Oh, I did note something very odd (and I submitted a bug report about it), the very last time I tested blogging by email. When I made my original tutorial post, I included some special code I use to color <div>'s, which looks something like: <div class="olive dotted">. It worked fine. Then, the last time I tested 'blogging by email', I used the EXACT SAME CODE, but the equal sign was converted to "=3D" and the post failed because it wouldn't pass the HTML-checker. I couldn't figure out WHERE the "3D" was introduced (and I still don't know). I checked the email header that was being sent to b2evolution and they weren't in the email (that I could see). I concluded that b2evolution was adding them, which was odd, because the first time I tested 'blogging via email', this wasn't an issue. Odd. (I've later learned that 3D is the CHR ASCII code for the equal sign, so it's not arbitrary ... knowing this still hasn't helped me solve the issue).

Without pinning down the source, the ONLY way I could get around the problem was by modifying the getmail.php file, around line 248, adding

"$content = str_replace('=3D,'=',$content);= "

(which simply collapses any "3D" that is found). (The fix will deprecate nicely IF it goes back to working properly, as that string will simply not be found).

Anyway ... I experienced a line break problem as noted in this morning's email. Turning to the PHP code, I've managed (I think) to find a work-a-round. Here's what you can add (again to the getmail.php file, around line 248). The red text needs to be inserted, to solve for the line break issue and collapse any multiple white spaces.

// CHECK and FORMAT content
$post_title = format_to_post ( trim($post_title), 0, 0 );
$content = format_to_post( trim($content), $Settings->get('AutoBR'), 0);
$content = str_replace ('=3D','=',$content); // if you're having problems with "=3D"
$content = ereg_replace("[\r\t\n]"," ",$content); // replace returns, tabs or newlines w/spaces.
$content = ereg_replace(' +',' ',trim($content)); // collapse white space

PS - I'll add this bit to the "blog-by-email" entry, when I get a chance. (This appears to work, but could use more testing to make sure. No time right now ... we're off to the ZOO today, to show Alex some lions and tigers and bears, oh my!)



Views: 30756 views
2 Comments · GuestBook
default pin-it button
Updated: 1-Dec-2005
Web View Count: 30756 viewsLast Web Update: 1-Dec-2005

Your Two Sense:

XHTML tags allowed. URLs & such will be converted to links.

Subscribe to Comments

Auto convert line breaks to <br />

1.flag Peter Weiland Comment
Hey Scott,

I reinstalled my server. Now the websites running in the root. Please remove "/b2" from the links. Oh, and it's .info by the way ;)
2.flag stk Comment
Geez ... finally got around to doing that. Oops!!

Thanks for the reminder.