December 16, 2013 8:01 pm

This guide will install webcam software that when configured will e-mail photos on motion detection. There is also a live action display, however, there is no option to connect securely to the live stream built in.  A VPN can offer this security instead.

This guide assumes you have already installed Raspbian, Raspbmc, or Xbian. It should work equally well with all of them. Do NOT use “sudo apt-get upgrade” with Raspbmc as this will most likely break things. Raspbmc has a different way of updating.
sudo apt-get update
sudo apt-get install motion postfix heirloom-mailx

Postfix will ask for some default options. Select “internet site with smart host.”

sudo nano /etc/postfix/

Add or change the file to include the following:

  • relayhost = []:587
  • smtp_sasl_auth_enable = yes
  • smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
  • smtp_sasl_security_options = noanonymous
  • smtp_tls_CAfile = /etc/postfix/cacert.pem
  • smtp_use_tls = yes
sudo nano /etc/postfix/sasl_passwd

Put “[]:587” with your username and password (without quote marks). If you are using 2 step authentication, you are going to need to create an application specific password from your gMail account settings.

sudo postmap /etc/postfix/sasl_passwd
sudo chown postfix /etc/postfix/sasl_passwd
sudo chmod 400 /etc/postfix/sasl_passwd

Validate certificates to avoid any errors.

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Finally reload postfix.

/etc/init.d/postfix reload

If everything is working properly:

echo "This is a test." | mail -s "Testing 1 2 3"

…will send a test mail to the account provided. This account does not need to be the same gMail account. The message will show up in your gMail sent messages.

Now lets finish up with Motion.

sudo nano /etc/default/motion

change  “start_motion_daemon=no” to  “start_motion_daemon=yes”

sudo nano /etc/motion/motion.conf
  • Daemon = OFF to ON
  • webcam_localhost = ON to OFF
The file also has some other useful settings you can play with though some have had problems with too high a frame-rate or too high a resolution. 2fps and 320×240 is a known safe option, although I’ve had some success with higher settings.

To have the software email photos of movement, you need to un-comment and edit the “on picture save line.” to read :

on_picture_save echo ‘Webcam Alert’ | mail -a %f -s “Webcam Alert”

The “webcam alert” text options are set to whatever you want as this is just the text that will show in the header and within the email body.

sudo service motion start


Categorised in:

This post was written by Tom


%d bloggers like this: