#!/usr/bin/env python

import smtplib
import sys
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

arg1 = sys.argv[1]
arg2 = sys.argv[2]

if arg1 == '1.000000':
   arg3 = 'op 1 complete'				#change 'op 1 complete' to whatever you want (leave the apostrophes)
elif arg1 == '2.000000':
   arg3 = 'op 2 complete'				#change 'op 2 complete' to whatever you want (leave the apostrophes)
elif arg1 == '3.000000':
   arg3 = 'cycle complete'				#change 'cycle complete' to whatever you want (leave the apostrophes)
else:
   arg3 = 'default message'				#this is what is sent (and can be changed) if you use *just* M101 with no P number.

sender = 'youremail@gmail.com'                      	#the gmail address goes here, the apostrophes are important
recipient = 'yourotheremail@randomemail.com'		#the email (or email-to-txt) you're sending to goes here
subject = arg3

body = ''						#leaves the body empty. 
#body = arg2 						#use this in the future if you want to pass a Q value, too

message = MIMEMultipart()
message['From'] = sender
message['To'] = recipient
message['Subject'] = subject
message.attach(MIMEText(body, 'plain'))

smtp_server = 'smtp.gmail.com'
smtp_port = 465

smtp_username = 'youremail@gmail.com'			#the gmail address also goes here, the apostrophes are important
smtp_password = 'password123456'			#your independent app password goes here, between the apostrophes

smtp = smtplib.SMTP_SSL(smtp_server, smtp_port)
smtp.login(smtp_username, smtp_password)

smtp.sendmail(sender, recipient, message.as_string())

smtp.quit()