NewsFeaturesDownloadsDevelopmentSupportAbout Us

Plugin moblog

From LifeType Wiki

Name: moblog

Download link:

License: GPL

Author: The LifeType Project


This plugin allows to easily post new articles via email or even MMS in those terminals that support this feature. The plugin can also handle attachments such as images or videos, and those will first be added as new files to the resource centre and then a link to these files will be added to the contents of the post. The text contents of the email will be published as a post in the main page, and assigned to the category that we select in the plugin configuration page.

How it Works

Email or MMS messages are sent to an email address that is especially set up for moblogging to LifeType (one e-mail address can be used to post to more than one blog. But if you use Realtime publishing it's also possible to use dedicated e-mail addresses per blog).

Attachments are extracted from the message and processed. All attached files will be saved to the resource centre and in the case of images, they will processed as any other image and different thumbnails will be generated. Once attachments have been processed, a link to the file or image will be added to the final post that will be published in the blog page.

It supports two different methods for publishing posts:

  • Realtime publishing (push method)
  • Batch publishing (pull method)

Sending Messages

Moblogged messages must have some mandatory information in them so that the plugin can identify who is sending the message and where it should be posted. A sample message could look like this:

USER: youruser
PASS: yourpassword
BLOG: your blog name
This is a very simple example message, which is 
being sent to blog 'your blog name', on behalf of 
user 'youruser' whose password is 'yourpassword'.

This message would post a new article to blog your blog name for user youruser and it would try to authenticate using password yourpassword. Needless to say, the lines containing this kind of information will be removed before the post is added to the blog.

In order to specify a topic for the post, we can use in order of importance:

  1. A TOPIC: yourtopic line in the body of the message.
  2. The 'Subject' header (if we are sending an email message)
  3. The first 50 characters of the body of the message, stripped of all markup

Additionally, we can use '"BLOGID: blog_id instead of BLOG: your blog name in the body of the message, if we know the internal identifier of the blog. Using the blog id is obviously much shorter to type in mobile devices.

In order to summarize, these are the "commands" that can be used within the message body:

  • USER: the name of the user on behalf of whom this article is going to be posted
  • PASS: the password in order to authenticate
  • BLOG: the name of the blog to where this is going to be published. It can include spaces if necessary and can be in either lower case or upper case.
  • BLOGID: instead of typing the blog name, we can use the blog identifier if we know it. Much easier to type.
  • TOPIC: allows to specify a topic for the post.

From the items above, USER, PASS and either BLOG or BLOGID are necessary in every message and please keep in mind that each one of these has to appear in its own line.

It is not possible to configure to which category posts are added in the message body, only via the plugin configuration page (see "User configuration options" below).


Before using this plugin, move the files moblog.php and moblogbatch.php from plugins/moblog/ to the root folder of LifeType (at the same level as index.php, admin.php, rss.php and so on). It is possible to leave it there by default but all examples in this document refer to moblog.php being in the root folder of LifeType.

Batch Publishing

This is the method you may prefer, if your blog is set up on a shared hosting or if you don't have access to the mailserver configuration and/or Curl. So if you don't know what Curl is, you probably want to use batch publishing. ;-) All you need to get up and running is POP3 access to an email account. Optionally access to some kind of cronjob can improve performance.

WARNING: you need an email account that is exclusively used for your Moblog. All messages in your inbox will be deleted no matter if they are valid moblog posts and get published or not. This will keep your moblog inbox clean from spam.

Configuring Batch Publishing

After installing the plugin you will get a new menu entry unter "Administration" called "Moblog Batch Settings". There are two ways to configure the batch publishing: Either you set up a batch job (aka "cronjob") that calls moblogbatch.php to check for new moblog posts or you let LifeType do the work uppon visitor requests ("Pseudobatch"). Needless to say that the second version may have a performance impact on visitors each time LifeType checks for new moblog posts. Thats why we recommend setting up a cronjob.

Batch Setup

As explained on the configuration page, you should set the "Pseudobatch" option to "disable" if you would like to set up a cronjob. A cronjob simply calls moblogbatch.php within a predefined interval. You can either use your servers cronjob feature or use one of the free cronjob services out there.

Your call to the script may look similar to this:

 /usr/local/bin/php5.cgi -d allow_url_fopen=1 /home/username/www/lifetype/moblogbatch.php silent

Pseudobatch Setup

The pseudobatch is the least efficient but the most simple method of setting up the moblog plugin. If you set the pseudobatch to, say, 10min, every visitor that requests one of your blogs pages will initiate a call to moblogbatch.php in the background, if it has been more than 10min since the last check to your moblog e-mail account.

Realtime Publishing

In order to get the push-method to work, it is necessary to have access to an email server running Postfix, Sendmail or similar SMTP server that accepts forwarding incoming messages to external commands via virtual (aliased) email addresses.

Additionally, the curl tool is also necessary in order to be able to forward email messages to a web server.

The e-mail address will be a virtual one, since the contents of the incoming email will be passed via standard input to curl, which will make an HTTP request to our moblog.php script. Moblog.php is the entry point to the functionality, and implements some code which is capable of parsing emails and extracting attachments from it.

Configuring Curl

curl is a commonly available tool in most Linux distros so there should not be any problem getting it to work.

Configuring the Email Alias

A dedicated email address is needed in order to use this functionality. The email address will be set up in the aliases file used by our SMTP server. Its location of this file may vary but it should be something like /etc/aliases or /etc/mail/aliases.

The new alias address should look like this:

moblog: "|curl -F message='<-'"

Once this new alias has been added, please do not forget to run the newaliases command.

In order to test this, please send a message to (please replace host names wherever relevant) If you wish to use a different email address, please replace moblog in the example above with your new address.

It is also worth mentioning that with this current configuration, this email address can be used as some kind of gateway for as many blogs as needed available in the current site, so there is no need to create a new email address for each one of our blog users (although this is possible, see the last section of this page)

If case of problems, one good way to debug possible SMTP server issues is by keeping an eye on the SMTP server log file and see if there is any error message in there.

User Configuration Options

The plugin adds a new configuration page for each blog under the Control Centre->Blog Settings, and it is necessary to first enable the plugin before using it.

In the plugin configuration page we can also configure the following things:

  • The article category to which new moblogged posts will be added. Just select one from the list of categories available in the blog.
  • The album to which attachments will be added.
  • When images are attached to images, this plugin will automatically include the image in the contents of the post, right below the content of the message. It is possible to choose how the image will be included in the post: as a small thumbnail, as a medium-sized thumbnail, or as full-size image. This setting defaults to a small thumbnail.
  • You can choose the "specify in email" option for either the global category or the article categories, which will allow the categories to be specified in the email (or on the curl command line).

The curl options are: -F articleCategories=1,2,3 -F globalCategory=3

The text of the email can have: cat:1,2,3 cats:1,2,3 category:1,2,3 categories:1,2,3 globalcat:1 globalcategory:1

(the 1,2,3 could be replaced with just one category in any of the above, the plural and singular versions will both parse one or many categories)

Compatibility List

Below you find a compatibility list of clients and mobile network operators. Let us know if you have tested the plugin with other clients or on other networks.

E-Mail Clients

  • Apple 2.0
  • Microsoft Entourage 2004
  • Horde IMP
  • Microsoft Outlook 2000
  • Mozilla Thunderbird
  • Gmail
  • GMX

Mobile Devices (either e-mail or mms)

  • Nokia N91
  • Nokia 7610
  • Nokia 9500 Communicator
  • SonyEricsson P800
  • SonyEricsson K700i
  • SonyEricsson K750i
  • Nokia 3100 works, but has problems with encoding.
  • Siemens M65 works, but has problems with encoding, especially german characters called "Umlaute" (e.g. ä, ö, ü)

MMS to SMTP Gateways

  • Elisa (Finnland)
  • Swisscom (Switzerland)

The feasability of moblogging via MMS greatly depends on the operator. Most operators have MMS-to-SMTP gateways that can convert MMS messages to valid emails, that can be processed by any email clients. However, how these email messages are created greatly depends on the operator.

This feature has only been tested with the Finnish mobile operator Elisa. Its MMS to SMTP gateway will reformat MMS messages to mail messages with MIME content multipart/alternative with at least 4 MIME parts: an HTML part with some information about the message, a plain/text part with the text contents of the body of the message, the image attached (if any) and a SMIL file with information about how to play the presentation/MMS message.

This plugin is capable of handling this kind of message. It will ignore any text/html and application/smil MIME parts and will use the text/plain as the body of the message, as many as it can find (it will basically append one after each other). Image attachments will be processed as expected.

In case you manage to successfully use the plugin in a different network, please update this page with the operator name.

Advanced Configuration

Automatically Register an Album and Category

If you would like to automatically set up a default category and default folder for your users, some modifications to dofinishregister.class.php are needed:

// create a new default category called Moblog
$article2Categories = new ArticleCategories();
$article2Category = new ArticleCategory( Moblog, "", $newblogId, true );
$moblogCat = $article2Categories->addArticleCategory( $article2Category );
// create a new default folder called Moblog
$moblogAlbum = new GalleryAlbum(
 $blogInfo->getId(), // id of the new blog
 "Moblog", // new name
 "Default category for moblog postings", // description
 0,  // no flags
 0,  // no parent id yet
 ,  // date not needed, will be set when adding the album
 Array(), // no properties
 true // the album should appear
$albums = new GalleryAlbums();
$albums->addAlbum( $moblogAlbum );
//enable the moblog plugin for each new user by default
$blogInfo->setValue( "plugin_moblog_article_category_id", $this->_categoryId );
$blogInfo->setValue( "plugin_moblog_gallery_resource_album_id", $this->_albumId );
$blogInfo->setValue( "plugin_moblog_resource_preview_type", 1 );               
$blogInfo->setValue( "plugin_moblog_enabled", 1 ); 

Forcing a certain blog ID and/or user name

If we find that typing USER:xxx, PASS:yyy and BLOG:zzz in every single message is too much (which could be a valid reason when using this plugin from mobile devices), it is possible to "hardcode" the user name and the blog identifier in the email alias, so we could rewrite the sample email alias from above as:

moblog: "|curl -F user=youruser -F blogId=1 -F message='<-'"

This means that we can also reduce the contents of messages that should be moblogged. The sample above could be reduced to the following contents, effectively removing the lines containing USER and BLOG:

PASS: yourpassword
This is a very simple example message, which is being sent to blog '
your blog name', on behalf of user 'youruser' whose password 
is 'yourpassword'.

The new email alias will default to using 'youruser' as the user name and '1' as the blog identifier, and this means that it will not be necessary to include this information anymore in the body of the email message. However, it is still possible to override these default settings by including again a USER and/or BLOGID (or BLOG) line in the body of the message, since the contents of the message will always take more priority than whatever was configured in the email alias.

NOTE: Passwords can be hardcoded in the email alias, but you should realize the security implications of that (which are two-fold) 1. If the email address is guessed, people can publish to your blog without asking you first. 2. The process list on the server will show the password on the command line, so if other people have access to the process list, they would be able to see the password, even if they don't have access to your alias file.

Enabling Logging

It is possible to tell the plugin to log messages to the standard log file (tmp/lifetype.log) for debugging purposes.

In the moblog.php file find the following line:

define( "MOBLOG_DEBUG", false );

and set it to true:

define( "MOBLOG_DEBUG", true );

Also make sure that the default logger is using the appender file instead of null, in config/

$config["default"] = Array( 
    "layout" => "%d %N - [%f:%l (%c:%F)] %m%n", 
    "appender" => "file",
    "file" => "tmp/lifetype.log",
    "prio" => "debug"

The plugin will log a lot of information so keep an eye on the size of the log file.

Known issues

  • There could be potential issues related to character encodings, specially when it comes to encoded file names (in the case of files with Chinese file names)
  • If you are experiencing some problems with this plugin and all you can see in the logs is something like this:
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] -- Initialized
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] -- message --
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] '<-'
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] -- end --
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] From REQUEST: user = - blogId =
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] parseBody ---> body =
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] There are 0 MIME parts available to parse
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] subject is = No Topic
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] user = ''
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] blog id =
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] topic = No Topic
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] reply to =
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] body =
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] User did not authenticate correctly.
12-10-2005 10:03:30 DEBUG - [mobloglogger.class.php:21 (logger:debug)] Response message sent! 

Please change the line in your /etc/aliases file to make it look like:

|curl -F message=<- http://.../plog/moblog.php

That is, without the single quotes surrounding <-

  • If using the lightppd web server, you have to add the following parameter to the alias calling curl to make it actually POST the info to the web page, otherwise lighttpd just ignores the entire request, without even logging anything:
-H "Expect:"