Kimler Sidebar Menu

Kimler Adventure Pages: Journal Entries

random top 40

Posting via Email

Filed in:b2evo

Posting via Email

April 6th, 2005  · stk

Hello World

This is a test of HTML

The above outlined text & color may not seem like such a big deal, but you might think it was a bigger deal if I told you that it was accomplished via email. That's right ... blogging 'on the run'!

"So how did you achieve such a feat?" you ask. Well, the answer, like so many others, lies in the questions that are asked on the b2evolution forums. Specifically, a fellow by the name of Matt, was looking for a blogging solution. He had heard that b2evolution did NOT support blogging via email and came to check this out for himself.

I picked up the torch because (1) I had chosen diary-x as a blogging solution in 2001 because it was the ONLY blogging solution I found (at the time) that offered blogging via email (our PCT journal was written using this software and you can see it here) and (2) I hadn't yet blogged by email and because I might want to one day, decided that NOW might be a good time to figure out how to do it!

There is a "How to post by email" tutorial, but it's based on version 0.8.6 and didn't do it for me. Further, as explained by this thread, many people have been experiencing problems trying to post via email.

This article will provide the means by which you too, can make b2evolution blog entries via email. Hopefully, with less of the frustration I experienced in doing it.


The tricky part of blogging by email is to get b2evolution "talking" to your POP3 email server. To be honest, I first tried my gmail account and could NOT get it to work properly. (Perhaps I'll revisit the issue, now that I have the e-blogging feature working, but on my first go, it just died a horrible death).

EDIT (9-Apr-05): I did, see "gmail" in the "Considerations & More Detail" section, below.

What does this say? Maybe that perserverence is KEY!

The only thing you need to change in b2evolution is the /conf/advanced.php file:

// ** Configuration for /htsrv/getmail.php **
// (skip this if you don't intend to blog via email)
# mailserver settings
$mailserver_url = '';
$mailserver_login = '';
$mailserver_pass = 'YourPassword';
$mailserver_port = 110;
# by default posts will have this category
$default_category = 32;
# subject prefix
$subjectprefix = 'blog:';
# body terminator string (starting from this string, everything will be ignored, including this string)
$bodyterminator = "END";
# set this to 1 to run in test mode
$thisisforfunonly = 0; ### Special Configuration for some phone email services
# some mobile phone email services will send identical subject & content on the same line
# if you use such a service, set $use_phoneemail to 1, and indicate a separator string
# when you compose your message, you'll type your subject then the separator string
# then you type your login:password, then the separator, then content
$use_phoneemail = 0;
$phoneemail_separator = ':::';

The items highlighted in green are the variables that you might/will need to change.

The Cron

The next step will be to set up a cron job that checks your email account every [x] hours, to see if there is a new (emailed) blog entry. This is fairly straight forward to do, especially if you have a host that has a cPanel utility. Simply log into cPanel and choose "cron". Using the 'Standard' or 'Unix' interface, select how often you want to check for email-blog updates (every hour would be a good choice, as more often than that will consume unnecessary server resources - if you can live with a longer time period, I would recommend it). After choosing this time period, you enter the command which, for me, looks like:

/usr/bin/php -f /home/randsco/public_html/blogs/htsrv/getmail.php

The Email

There are several things that you must do to successfully obtain a blog via email. Here is a short list:

  • The "To:" field - This may seem stupid, but make certain that you're sending the email to the same email address you added in the advanced.php file.
  • The "Subject:" field - Make certain that the subject begins with the "$subjectprefix" variable, as defined in _advanced.php. (The default variable is "blog:") The remainder of the subject will be your blog title.
  • The "body" - Make certain that the first line of the body text is your b2evolution login name and password, in the format: username:password. The second line will either begin the actual blog entry or override the default category defined in _advanced.php. (To override the default category, use <category> ### </category>, where ###="Category Number" detail). Then comes your blog entry. Feel free to use XHTML-valid tags, such as <div class="whatever"> </div>; <p class="paragraph"> </p>; etc., as these will be rendered properly in the final blog entry.
  • The "end" - Be sure to end your blog entry with the same characters as defined in the _advanced.php file ($bodyterminator). This defines the end of the blog entry. Any text after this, will be ignored. (Which is especially useful, if you are using a service that appends advertising on the end of your emails.)


How will you know if you are successful? Good question. Well, for starters, once you get everything in position, I'd recommend testing the whole thing MANUALLY. The easiest way to do this is to open a new browser window and type "" into the address bar (your URL may be different). This will fire off the "getmail.php" job. If it is successful, you should see a screen that looks similar to the one on the right.

When I finally got the blog-via-email thing first working, I didn't see this message and instead, saw the one on the left. This SQL error turned out to be a bit more serious than I originally thought. Initially, I ignored it, because my emailed blog was posted (who cares about a ping failing?) Well, in the end ... ME! The reason: When getmail.php fails at this point, it doesn't finish. One of the last and VERY IMPORTANT things it does, is DELETE the successfully uploaded blog email. (If it's not deleted, each time the crontab job runs, it will re-post that SAME email ... over and over and over. For testing purposes, I had set my cron job to run every 5 minutes ... so it didn't take me long to figure out what was happening).

Don't worry, the fix is easy. A suspected bug in the _functions_pings.php file (see bug report) appears to be causing the problem. The odd thing is that the bug doesn't occur when saving an entry from the back office - only when submitting an entry via email. The present work-a-round is to simply not ping

Turn off the ping to

Go to the back office -> Select "Blogs" tab -> Select blog -> Select "Advanced" tab -> Uncheck "Ping"

You won't get any feedback from the crontab job, so the only way that you'll know if the emailed entry was successfully picked up by b2evo will be (a) it shows up on the blog & (b) the email will be deleted whenever the crontab is successfully run.

This pretty much concludes the email-blog tutorial. If you have any questions, please feel free to ask. But be warned, I'm neither a b2evo-email-blog guru, nor a php/pop3/html/css/b2evo/blogging guru ... so, be gentle!

Hope this helps

Considerations & More Detail

I'll expand this section as more questions come in, but I'll start off with a few items that may need explaining.

• First, b2evo email updating requires an email account with POP3 access. (No IMAP support, yet.)

• Second, it does NOT allow html updates (you can't insert images, make text bold, add backgrounds, etc., within your email client and email it to b2evo, expecting it all to be properly rendered). The entry will be posted, but all the fancy formatting will be stripped off.

gmail (9-Apr-05) As I discovered (and Collin pointed out in a comment), gmail requires a SSL connection for POP3 access. The script does not support a SSL connection and fails to connect to gmail accounts. I have put in a request to have SSL support added.

Selecting Categories (11-May-05) You can override the 'default category' in the _advanced.php file by typing <category> ### </category> in the body of your email, where ### is the "category number" (or "catID"). (There are several methods for determining the category number, but perhaps the easiest is to mouseover the category name, either on your blog or in the Back Office, and look in the status bar. You'll see the category link, which shows the category number "cat=###" at the end. Also, don't put <category> ### </category> on the first line, with the username:password, because the username & password must be on the first line, all by itself. Put it on line 2, instead.) - A special thanks to Charles for figuring this one out and passing it along.

QMail & non-RFC1939 Compliant Mail Servers (25-May-05) If you receive the following error message when you run the getmail.php script manually:

Connecting to pop server... Connection failed: POP3: premature NOOP OK, NOT an RFC 1939 Compliant server

It might be fixed by modifying the /b2evocore/_class_pop3.php file, around line 132. Look for the lines in gray and ADD the line in red. (Apparently, qmail and some other mail servers, are not 100% RFC 1939 compliant).

$this->RFC1939 = $this->noop();
return true;
if($this->RFC1939) {

Unwanted Line Breaks (25-May-05) You may find that your email client textbox window adds hidden escape sequences to your emailed posts. You won't "see" these, because they are hidden, but you WILL notice undesirable line breaks in your emailed post. (See this entry for more detail). The fix is to add these two lines to your getmail.php file around line 248 (the lines in gray are for reference):

// 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 = ereg_replace("[\r\t\n]"," ",$content); // replace esc codes w/spaces.
$content = ereg_replace(' +',' ',trim($content)); // collapse white space

Post Not Showing (25-May-05) Some folks are scratching their head: "Why is the email-by-post successful, but nothing shows up on my blog?" (See Si's comment #11 below). The answer may be that the email timestamp (for a variety of reasons), is in the FUTURE. If this is the case, you won't see the post on your blog until enough time has passed that the post is now in the present. Look in your blog for an unpublished, future post. If need be, correct your local regional time settings in the back office (Settings tab -> Regional -> Time Difference).

Views: 18580 views
50 Comments · GuestBook
default pin-it button
Updated: 23-Aug-2006
Web View Count: 18580 viewsLast Web Update: 23-Aug-2006

Your Two Sense:

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

Subscribe to Comments

Auto convert line breaks to <br />

1.flag Collin Comment

Just read your tutorial--it's great.

To be honest, I first tried my gmail account and could NOT get it to work properly. (Perhaps I'll revisit the issue, now that I have the e-blogging feature working, but on my first go, it just died a horrible death).

Gmail's POP3 server ONLY supports SSL connections... I don't believe the PHP script supports this; perhaps this is the reason you could not get your Gmail account working with the b2evolution blog-by-email. Just a suggestion.

2.flag stk Comment
Collin, I have revisited the gmail issue and came to the same conclusion, but haven't added it yet. You beat me to it!
3.flag Scott Kelley Comment
What about responses?

Will Subject: Re: blog: [SUBJECT] be included as a comment?

If not, it seems like this would be easy enough to implement and would be very cool.

4.flag stk Comment
Sorry for the delay, Scott, but no, the current implementation of the Blog-by-Email feature does NOT include the capability to send comments. (i.e., the "Subject" Re: blog: [SUBJECT] would result in a new post, titled "SUBJECT" and not a comment).
5.flag Sieg Comment
All right Ill give it another shot, I tried setting this up months ago and got so mad I said to hell with it. Here we go.....
6.flag Tyler Comment
Thank you so much for such an amazing post, it helped me setup QUICKLY ..THANK YOU..

One question: How can I denote that a certain blog entry by email goes to another category BESIDES the default category setup in adv.php?
7.flag stk Comment
Glad you found the tutorial useful, Tyler and GOOD question. (I've known the answer for a while, but neglected to post it ... but now I will). Have a look above. -Cheers
8.flag grasland Comment
Hi, great addition to the story on the b2e-site! It helped me a lot. I have one question with which maybe one of 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 this page). Any idea how to solve this? I tried the paragraph-class but this did not solve it. Thx in advance.
9.flag stk Comment
Did the same thing for me and I think I have a fix ... (see my quick fix ... which I'll incorporate into this post sometime). Not today though - we're headed to the ZOO!
10.flag grasland Comment
It works fine for me Scott! Thanks very much for the quick reply and solution! Say hello to the penquins ;)
11.flag Si Comment
Man this is proving troublesome!

Hey Scott, I've gone over yours and b2evo's directions and yet I still can't make it work. I've run the getmail.php file manually and it accesses the server, collects the email, deletes the email......but doesn't post the email onto the blog! Any ideas!?
12.flag stk Comment
Si, because it is deleting the email, it is successfully runninng.

Check the Back Office. The timestamp on the email might be in the FUTURE. If so, then the post will be in the DB, but because it's in the future, won't be
seen on the blog until that time period has passed.
13.flag Si Comment
Bingo! That was it! Thanks so much ... I use a UK server but posted from the Netherlands (+1hr) and that caused the issue! Once the time had
passed, as you predicted, the post appeared! Thanks so much for your reply ... now all I need do is turn on the Crontab and it'll take care of itself!

Thanks once again!

14.flag Daethian Comment
Okay months later I'm trying again. Same error... wrong login or password and its not wrong. any ideas?
15.flag stk Comment

My wife and I cycled through Newcastle on the 1999 "Big Ride" Across America, on our way from Seattle to Washington D.C. Small world.

We're presently on vacation. I've sent you a private email and when we return, I'll email again and see if we can get this sorted for you.

Cheers, Scott
16.flag Stuart Comment
I'm a bit late to the party, but just wanted to say thanks for putting this guide up, it works perfectly.
17.flag stk Comment
Stuart -

I think you've shown up "fashionably late"

Glad it helped. Thanks for taking a moment to tell me.
18.flag Sam Comment
how do we send photos by email to the blog?
19.flag stk Comment

Good question. Sorry, but I don't currently have a work flow for emailing pics to b2evo (via email).

I have only leads, which may help:

1) Bl@g (a b2evo add-on that allows uploading of attachments, including photos).

2) Flickr is a free tool that you (apparently) upload images to (via email), then blog from (to b2evo) via email.

Hope this helps.

20.flag Unwanted Lines Breaks Solution Comment
Iam just get around working with your EMail to blog help.
The Solution for the line breacks you offerd was not so fine .
It starts to macke a block of the text .even worser on biger emails
than the line breaks any other solution for geding rid of the line breaks and hold some style in the email/post.
21.flag TugBoat Comment
One thing that could be mentioned is how to direct e-mails to different blogs.

It's pretty simple, first make sure the user has access to that blog by modifying the permissions tab under the blog.

Each category created for each blog with then have a unique number which the tutorial above mentions how to find. Once you know the number, then use it inside the tags in the e-mail to change blogs. When the e-mail arrives, it will be put in the right category and the right blog. Works here. Cheers, Tug.
22.flag TugBoat Comment
I mean inside the category tags /
23.flag jason Comment
Excellent tutorial! Easy to follow! Kudos. On a related note, how can I tell my server to delete the email from the box once the posting process is done. Anyone have a hint?
24.flag Pat Comment
I am excited about the possibilities of posting emails to a blog. How do I disable the comment function when the email is posted? Is there a line of code or a setting somewhere?
25.flag Kelton Comment
My first problem was non RFC compliant mail server on my host. Used your tip to fix that problem. Now starts processing;
Connecting to pop server...
Logging into pop server...
Getting message #1...
Then after the message is read gives
Wrong login or password.
I know I have the correct login and password in the first line of the email.
Any idea how to fix this?
26.flag Eddie Comment
Hi Scott, thanks for this usefull description of the eMail function. For me it works like a charme :)
My next steps are to have Cron working now. Could you please help me in a) finding cPanel and b) setting it right? Furhter, do you have already an answer to the gMail/SSL questions?
27.flag stk Comment

Glad you found it useful.

Is your server a 'Nix-based server (UNIX, LINUX) or windows? ("cron" is really a UNIX construct. I don't know what the windows equivalent might be).

Not all host providers use 'cPanel' as a back-office administration tool, but many do.

I'd recommend contacting your host provider and tell them that you want to fire off the getmail.php script every so often and ask them if they can help you get it set up.

Let us know how it works out. (Post back here about the specific syntax, as it might help someone else).

Regarding Gmail and SSL ... I've not modded the script to provide SSL support, nor do I know anyone else that has. I'm afraid we're still out of luck there.

Hope this helps.

28.flag LiquidFire Comment
Hi there!

As all here I found your article, so far, very helpfull. But I have the same problem as Daethian (comment 14). It complaints about my password/login. I checked it now more times and just reset the login details to what I used in the mail ... no change. Since I am now busy to get this working for a couple of hours, I really would appericiate your help. Soon is my holiday comming up and I really would love to use this feature.

I also have to admit, I don't understand how to set up a cron job. Don't know what a cPanel is and where to find it.

Thanks in advance.
29.flag stk Comment

Thanks for trusting me with your login info. After looking around your Sparkle blog (v0.9.2), I noticed two things:

1) Your default category (set in _advanced.php to "1") does not exist in your blog. You need to pick a category number that you actually have used. To find a number hover over a category, either on your blog or in the back office, then look at the status bar for the link, which will include the category number.

2) It turns out that getmail.php was failing on the login information. Your test email had some HTML tags in front of the "user:pass" line (as shown in the "raw data" echoed during a manual getmail.php run. The solution? Make sure that the email you send is "text only" and doesn't contain any (hidden or otherwise) HTML tags.

I did a test post and GREAT NEWS! ... everything is working! Have a safe and fun holiday.

30.flag LiquidFire Comment
Wow ... it really works ... even from the mobile ... certainly I will bookmark your page ;-)

Thanks, you are an angel.

I wish my web space admins were as professional as you (still waiting for help with my php gallery attempt on a simple question - just need to know if something is installed on their server ... but well)

Then i just need to get into an Internet cafe once in a while ... ;-) ... but that's OK.

31.flag Eddie Comment
Dear Scott

I also tried to do an eMail posting with multiple Categories as Tyler (entry #6) posted. Unfortunately I didn't find your added Text (you entry #7).

I have about 3-4 Categories my post should be assigned to. Can you please help on this?
32.flag stk Comment

I should have linked the text (and have done so). I apologize.

However, you mention multiple categories. The technique described above only deals with a SINGLE category. You'll have to experiment, to see if you can assign multiple categories to a post made via email. (I'd try changing the delimiters in the above method ... commas, spaces, etc ... to see if this achieves what you want).

If it does, please write back, so I can add this capability to the list.


33.flag Eddie Comment
Thanks Scott for your reply. You linked to this same page (hehe) that was simple. Anyhow I will try further and should I find out I will let you know.
34.flag Eddie Comment

I have tried to post through eMail, declaring more than one Category ID. Unfortunately this does not work. I have tried to separate the ID's with "," ";" and spaces, but to no avail. It seems that we have to stick to the 1 Category ID, unless someone comes up with a solution.
35.flag stk Comment

Thanks for the followup. I suspect that the 0.9 series of b2evolution won't be worked on, as much, considering that the new series (1.0+), with it's completely rewritten, object-oriented core, will likely consume most of the development time.

Version 1.8 beta was just released a few days ago.

Hopefully, they'll be more support for blogging by email, in this newest version.

36.flag Eddie Comment
Thanks for this information. Scott, do you also have a Informative Posting on Trackback?
37.flag Sharon Comment
Hello, I too am getting wrong login and password. I'm posting to a valid category and triple triple checked the user/password. I'm sending email in simple text, still with no luck. Any other wordarounds?
38.flag stk Comment

What version of b2evolution are you using?
39.flag Nelson Comment
Hi Scott,
Do you know why I would keep getting "Blog by email feature is not enabled." everytime I try to run getmail.php manually? I can't seem to find any settings to enable it anywhere.

40.flag Nelson Comment
Sorry I just found it in the Backoffice. Now I get errors and I'm on the same page as others. Sorry about that
41.flag Tony Comment
Any ideas on how to fix the timestamp problem? Posts from my PDA are off by 4 hours and posts from webmail are off by 1 hour. The time displays correctly everywhere but in b2evo.
42.flag Robb Comment
This tutorial is right on the money, great job. However I'm having some problems.

I'm using the latest version 1.9.2 and I set up my pop3 stuff in the backend App Settings/Features tab. I then clicked the connection link and everything worked fine Logged onto my mail server published the post and deleted it off the mail server, even threw it into the correct category. I then set up the cron job on my server and set up a eail forward of the cronjob progress.

1st - with my install the getmail.php is in the /cron directory, no big deal I change the cron job to cron/ instead of htsvr/.

2nd - There is no code in the _advanced.php that even remotely says anything about the mailserver like the example here. Do I have to put all this code into this file. I figured I did not have to since when I use the App Settings/Features/Connection Link everything works fine.

Well it works through the above link but when my server performs the cron this is the message it returns. ?php: No such file or directory =: command not found /backup: is a directory Transfer: command not found Transfer/: is a directory line 8: syntax error near unexpected token

`dirname(_' line 8: `require_once


These are some serious error messages. Can this be due to #1 and #2 above, a bad install even though I haven't moved any files.

Any thoughts or comments would be appreciated,especially from someone out there with 1.9.2 installed and receiving email posts.

Thanks in advance, Robb
43.flag stk Comment

Your "1st" and "2nd" relate directly to the fact that this post was made during and for the v0.9.x series of b2evolution and you're using v1.x.

The location of getmail.php has changed and many of the settings are now in the back-office under "App Settings" -> "Features" (Blog by Email)

1) I've not tested "blog by email" in my 1.9.2 version.

2) You can run the "getmail.php" file directly, by typing it into a browser ( - ish, which saves you from having to wait for a cron.

3) The errors you're getting from getmail should have line numbers associated with them? Also (at least it used to be this way) ... the incoming mail formatting can really toss getmail.php for a loop. (mail from one client can pass through no problem, yet another one can't get past the password and such).

Still, you're errors appear v.unusual. How did you install b2evo? (Fantastico or manual? If manual, check to make sure the whole getmail.php file got transferred correctly).

From where are you sending your blog email? (Try a basic POP3 account in another location).

My experience: getting 1st contact is tough. Once you get it ... you're fine.

Try the forums too. (Read: I probably won't have a chance to test/play with "blog-by-email" for a while).

Also ... if you do find a solution, please come back and say what it was that fixed it (it might help others).

Good luck. -stk
44.flag Robb Comment
Thanks Scott for the timely reply. Gave me a few things to think about. I did the direct call of the getmail.php by typing it's location into the address bar. Everything worked fine, logged in downloaded, posted in the correct blog and category, and then deleted off of the mail server. So this leads me to think it's something on my server side and/or cron job. Very odd, but I will be tinkering with it, and when I find out what the problem is, I'll post it here.

One other thing if you don't mind. In the above post #9, when you were going to the zoo, you placed a link that adressed concerns with the formatting of the e-mails. All my tests were one word content "test", but now I have started longer posts and notice an extra line break in odd places. Your link above for the "quick fix" no longer points to a post and I was wondering if you could re-post that quick fix.

Once again, Kudos to you for this tutorial, you did a great job.

45.flag Robb Comment
Oops... Answered my own question about formatting. v1.9.2 under the App Setting->General tab you have to make sure that the following is unchecked, or checked depending on what's happing with your config.

tags to mail/MMS posts
46.flag stk Comment

The correct link is already in "More Detail", at the end of the post - "Unwanted Line Breaks".

But you're right, I missed changing the link in comment #9.


Glad you found the post useful and definitely report back on your cron solution (you're using the b2evo cron or your host's?). Again, I've not played with b2evo's, since they made one available.

47.flag Pierre Comment
I come after the fight, one year after.
But still have some questions:
I am trying to find a solution for forwarding HTML mails to my B2evolution blogs categories.

In fact, should I go on with B2evolution? or should I try another software? Who can advice?

Thank You, a Breton from Brittany (France) living in Russia!
48.flag stk Comment

Fight? You lost me on that one.

Forwarding email to your blog? Hmmm. Should just be a matter of changing the TITLE and including the user/pwd info in the first couple of lines? (Never tried it).

If you want to change blogging applications, I'd recommend WordPress. It seems to be quite popular.

-stk - a Californian from California (U.S.A.), living in Canada. :p
49.flag Pierre Comment
Thank you for responding!

Yes, in fact I succeeded with forwarding mail as you said in plain text only. But my target is to post-it directly without checks and in HTML with associated photos!
To create a rule …to add the needed code automatically…to observe the mail appearing in one category of one blog alone…

I know it is difficult but maybe one file in php exists or one way to archive this function?

What do you think?

A dreamer in St Petersburg…
50.flag karen Comment
hi stk,

does this still work with b2e 2.0.2? coz i was trying it but cant find the code for the conf/advanced... pls help me again. thanks.