1. Install Mutt email program
sudo apt-get install mutt
2. Make a .muttrc file
set imap_user = from_my@gmail.com
set imap_pass = verygoodpasswordhere
set smtp_url = smtp://from_my@smtp.gmail.com:587/
set smtp_pass = verygoodpasswordhere
set from = from_my@gmail.com
set realname = seuritycamera
set folder = imaps://imap.gmail.com:993
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 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
start_motion_daemon=yes
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/.startup.sh
--------------------------------
4. Make a startup script
#! /bin/sh
sleep 40 && cd /home/username && ./.mutt.sh
Make the script executable
chmod a+x /home/username/.startup.sh
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” -- to_some_email@gmail.com from_my@gmail.com < /dev/null
Make the script executable
chmod a+x /home/username/.mutt.sh
Make three folders
/path/motion
/path/allvideos
/path/toemail
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