Email

What it is for

Your server can send you emails from your rules: warning you that an alarm went off, that a door was left open, that a temperature is abnormal, or sending a picture taken by a camera.

For that, you must tell it which sending service to use: this is called an SMTP server. In practice, the one from your Internet provider or your mail service.

These settings are not available from the touchscreen: connect over SSH (see SSH access).

What you need

Before you start, gather the information provided by your mail service:

  • the address of the sending server, such as smtp.example.com;
  • the port to use, often 587 or 465;
  • your user name and password, if the service requires authentication;
  • whether the connection must be encrypted (TLS), which is the case almost everywhere today.

This information is in your provider’s help pages, often under a heading such as “configure a mail client”.

Configuring

The settings are defined with the calaos_config tool:

calaos_config set smtp_server smtp://smtp.example.com
calaos_config set smtp_port 587
calaos_config set smtp_auth true
calaos_config set smtp_tls true
calaos_config set smtp_username my_user
calaos_config set smtp_password my_password

Here is what each setting does:

SettingPurpose
smtp_serverAddress of the sending server, prefixed with smtp://
smtp_portPort of the sending server
smtp_authtrue if the server requires a user name and a password
smtp_tlstrue for an encrypted connection
smtp_usernameYour user name
smtp_passwordYour password

To check what has been saved:

calaos_config list

Many mail services now refuse your usual password for this kind of use and require an application password, to be generated from your account. If sending fails while your credentials are correct, this is very likely the cause.

Testing

The calaos_mail tool sends a test message. First prepare a file containing the message text, then send it:

echo "This is a test from my Calaos server." > /tmp/test.txt
calaos_mail --from me@example.com --to me@example.com --subject "Calaos test" --body /tmp/test.txt

If the message arrives, the configuration is correct.

If it fails, run the command again adding --verbose: the details of the exchange with the sending server are displayed, which usually shows which setting is at fault.

calaos_mail --from me@example.com --to me@example.com --subject "Calaos test" --body /tmp/test.txt --verbose

Remember to check your junk mail folder: messages sent by a home server often land there the first time.

Attaching files

The --attach option attaches a file, and can be repeated to attach several:

calaos_mail --from me@example.com --to me@example.com --subject "Picture" --body /tmp/test.txt --attach /tmp/photo.jpg

This is the mechanism that lets you receive a camera picture by email.

Using email in your rules

Once sending is configured, you can trigger emails from your automation rules. Creating rules is described in Rules, in the Calaos Installer chapter.

Being warned automatically

Independently of your rules, the server can alert you on its own about two events concerning your wireless devices:

# Low battery on a device
calaos_config set notif/battery_mail_enabled true
calaos_config set notif/battery_push_enabled true

# Device connecting or disconnecting
calaos_config set notif/io_connected_mail_enabled true
calaos_config set notif/io_connected_push_enabled true

The _mail_ settings send an email — and therefore assume the configuration above — while the _push_ settings send a notification to your phone. You can enable either, or both.

The low-battery alert is the most useful one: it warns you before a sensor stops working, rather than letting you find out on the day you need it.

See Zigbee for the devices concerned.