#Created by - Carmelito Andrade for the Security Camera
import smtplib, os
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import Encoders
gmail_user = "from email" # replace with the email id you created for your Security Camera , which is going to be the from email
gmail_name = "Name on the email account" #name something YunCamera email
gmail_pwd = "xxxxxxxxxx" # Password for the above email id
attach='/mnt/sda1/YunCameraPic.png' 
body ="Hi ,\n\nYou have some one at the door,check out the picture below.\n\nThanks\nSecurity Camera"
msg = MIMEMultipart()
msg['From'] = gmail_name
msg['To'] = "your email id"# Your email Id
msg['Subject'] = "Some ones at the door"
msg.attach(MIMEText(body))
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(attach, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition','attachment; filename="YunCameraPic.png"' % os.path.basename(attach))
msg.attach(part)
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(gmail_user, gmail_pwd)
mailServer.sendmail(gmail_name, "from email", msg.as_string())   #replace this with the secuity cameras email id 
mailServer.close()
