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.
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/main.cf
Add or change the file to include the following:
- relayhost = [smtp.gmail.com]: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 “[smtp.gmail.com]:587 firstname.lastname@example.org:password” 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_passwdsudo 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.
If everything is working properly:
echo "This is a test." | mail -s "Testing 1 2 3" email@example.com
…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
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” firstname.lastname@example.org
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: Raspberry Pi
This post was written by Tom