HAH control via email (pop)

6 replies [Last post]
Providence, United States
Joined: 9 Jan 2010

This applet allows you to SEND a command to an email account which the HAH monitors.

It works like this:
In the subject line you can specify one of the following

  • xap-raw
  • xap-short
  • xap-alias

These are all configured via a lookup table so feel free to make up your own commands if you wish.

Depending on what you have here the content has variant behaviour:

  • xap-raw - means the body must be a fully compliant xap packet.
  • xap-short - you can use my xap short encoding format.
  • xap-alias - it will send a xap payload that is conformat to that which you get from xap-twitter and xap-googlecal, so you also need the aliasApplet.lua running if you want to catch these and perform some action.    To refresh you memory that xap packet will look like this  http://www.dbzoo.com/livebox/hah#calendar_aliases  The body of a xap-alias must only have 1 line, well only the 1st will be taken in any case.

You'll need to adjust the obvious settings for configuration of the email and pop server.


  1. Copy the pop3Applet.lua into the /etc/plugboard directory.
  2. The other files must be put into the directory /etc/plugboard/pop3

That is quite important otherwise it just won't work.

The POP port is hardcoded to 110 and username/password will be cleartext.  Secure MD5 (APOP) is supported via port 110 too - Plenty of online MD5 generators - http://www.miraclesalad.com/webtools/md5.php

A more secure connection would be like this - note: this is NOT SSL and GMAIL *only* accepts SSL, so this won't work with a gmail account or possibly others that only allow secure connection types.  I've not tested them all, but it works for me.

local popConf = { 
                   pass="MD5HASH OF PASSWORD",
                } �

Example email using a SHORT message

subject: xap-short

Example alias command - and you must have something running to pick up this message, like the aliasApplet.lua !

subject: xap-alias
relay 1 on

init.lua7.42 KB
message.lua5.27 KB
pop3Applet.lua2.41 KB
United Kingdom
Joined: 11 Jun 2010
Not Processing E-Mails

Can't seem to get this to work.  I can see that my e-mails have been opened but the script, but it doesn't action them.  I know you had some problems with the encoding early on, could this still be a problem, I've included the e-mail source below, any pointers greatly appreciated.


Return-Path: <myemail@domain.com>
X-Original-To: myhah@domain.com
Delivered-To: myhah@domain.com
Received: from mx03.one.com (mx03.one.com [])
by mail86.b-one.net (Postfix) with ESMTP id 4275D1012B00
for <myhah@domain.com>; Wed, 30 Nov 2011 17:35:27 +0100 (CET)
X-Virus-Scanned: by one.com
Received-SPF: pass (mx03: domain of myemail@domain.com designates as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-iy0-f169.google.com (mail-iy0-f169.google.com [])
by mx03.one.com (Postfix) with ESMTP id B90BE20F3FF8
for <myhah@domain.com>; Wed, 30 Nov 2011 16:35:26 +0000 (UTC)
Received: by iaqq3 with SMTP id q3so1380377iaq.14
        for <myhah@domain.com>; Wed, 30 Nov 2011 08:35:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
MIME-Version: 1.0
Received: by with SMTP id z2mr3980750icw.13.1322670926029; Wed,
 30 Nov 2011 08:35:26 -0800 (PST)
Received: by with HTTP; Wed, 30 Nov 2011 08:35:26 -0800 (PST)
Date: Wed, 30 Nov 2011 16:35:26 +0000
Message-ID: <CAO4zjtTqCeSQunLgdyMyWZKicz+qHsr2r+_pHV4-Dr9qYF7dXw@mail.gmail.com>
Subject: xap-alias
From: Karl Cookson <myemail@domain.com>
To: myhah@domain.com
Content-Type: multipart/alternative; boundary=90e6ba6e819eb3649904b2f6528e

Content-Type: text/plain; charset=ISO-8859-1

relay 1 on

Content-Type: text/html; charset=ISO-8859-1

relay 1 on




Providence, United States
Joined: 9 Jan 2010
The script does not action them.

As your subject of the email is "xap-alias" this just sends out an ALIAS xap message, you need to have YET another script running that can pick these up and interpret what to do with them.

You should see this message being emitted when the email is processed.

text=relay 1 on

There is an alias interpreter applet sample supplied on the HAH that can get you started with how to then action this message.

If you want to turn on a relay directly and not via an alias then you would need the subject to be "xap-raw" or "xap-short" and you would need to have as the body the corresponding xAP payload.


United Kingdom
Joined: 11 Jun 2010
The aliasApplet is running, I

The aliasApplet is running, I use it with GoogleCal.  I can't see that xap message under dbzoo.livebox.plugboard, I'll do some more testing tomorrow, I'll also try xap-raw and xap-short.


Joined: 23 Oct 2011
Not sure why but..

I am trying to get the HAH control via e-mail.  I have setup the pop3Applet in etc/plugboard/ with correct host,user,pass [I am not opting to use the secure=true bit as indicated above and I have also managed to telnet ontothe pop server okay with the same details, so that shows the login works.  This is also mirrored in the debug logs for the xap-plugboard which shows the pop3Applet has been loaded and the logs show a few cycles of login to check the mails.  The plugboard then stops with this inbetween the last login to the pop3 server

POP3 RESPONSE : +OK 24 896
+OK 24lua: /etc/plugboard/pop3Applet.lua:54: attempt to index field 'pheader' (a nil value)
stack traceback:
/etc/plugboard/pop3Applet.lua:54: in function 'decodeBody'
/etc/plugboard/pop3Applet.lua:89: in function </etc/plugboard/pop3Applet.lua:88>
[C]: in function 'foreach'
/etc/plugboard/pop3Applet.lua:88: in function 'callback'
/usr/share/lua/5.1/xap/init.lua:172: in function 'dispatch'
/usr/share/lua/5.1/xap/init.lua:124: in function 'fun'
/usr/share/lua/5.1/pl/list.lua:360: in function 'foreach'
/usr/share/lua/5.1/xap/init.lua:122: in function 'process'
/etc_ro_fs/plugboard/plugboard.lua:77: in main chunk
[C]: ?

The plugboard then stops.  It has never processed test mails as xap-short, xap-alias, and xap-raw message.  I presume it's something to do with the pop3Applet.lua and init.lua that resides in the plugboard/pop3 folder but not sure what.

Any help welcomed and much appreciated


Glasgow, United Kingdom
Joined: 26 Oct 2009
A wide variety of flavours

Email is a big, complex, thing. This is why the O'Reilly Sendmail book has 1050 pages!

I reckon that the format of the email from your provider is subtly different from the ones that were used to test the script. As a workaround, perhaps try using another email provider.

Joined: 23 Oct 2011
Yes, I had issues with sending mail too

But managed to get that going.  It's just the receive bit.  I will have a look for a different e-mail provider ta Derek

Hardware Info