Set Motion as e-mailing Security Camera

1. Install Mutt email program

sudo apt-get install mutt

2. Make a .muttrc file

set imap_user =
set imap_pass = verygoodpasswordhere

set smtp_url = smtp://
set smtp_pass = verygoodpasswordhere
set from =
set realname = seuritycamera

set folder = imaps://
set spoolfile = ”+INBOX”
set postponed=”+[Gmail]/Drafts”

set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates

set move = no
set record = ’+Sent’

3. Test Mutt before installing Motion and then install Motion

sudo apt-get install motion

Add yourself to the motion group

sudo adduser myself motion

Configure Motion

gksu pluma /etc/default/motion

# set to ’yes’ to enable the motion daemon

gksu pluma /etc/motion/motion.conf

… edit these lines

# Minimum time in seconds between capturing picture frames from the camera.
# Default: 0 = disabled – the capture rate is given by the camera framerate.
# This option is used when you want to capture images at a rate lower than 2 per second.
minimum_frame_time 1
# Target base directory for pictures and films
# Recommended to use absolute path. (Default: current working directory)
target_dir /path/motion
# Command to be executed when a motion frame is detected (default: none)
on_motion_detected /home/username/

4. Make a startup script

#! /bin/sh
sleep 40 && cd /home/username && ./

Make the script executable

chmod a+x /home/username/

5. Make video + email script

#! /bin/sh
TIMESTAMP=$(date +%Y%m%d%H| sed ’s/ //g’)

find /path/motion -iname ”*.swf” -exec mv {} /path/allvideos \; && sleep 30 && genisoimage -o /path/toemail/video$TIMESTAMP.iso /path/allvideos && mutt -z -a /path/toemail/video$TIMESTAMP.iso -s “Security videos” — < /dev/null Make the script executable chmod a+x /home/username/

Make three folders

Set the permissions for the folders
sudo chmod 775 /path/foldername

6. Add Motion to the startup applications and or crontab

PS. emails comes always when Motion has react!

WordPress shows some lines wrong, so use this document.

See also Motion live stream via browser