60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
from twilio.rest import Client
|
|
from smtplib import SMTP
|
|
from email.mime.multipart import MIMEMultipart
|
|
from email.mime.text import MIMEText
|
|
from email.mime.base import MIMEBase
|
|
|
|
# Twilio Account Setup
|
|
account_sid = 'AC051785f6dd5a93184641d01103eb8cd4'
|
|
auth_token = 'd40c831e56785afaa9294fd3c5a88e6e'
|
|
client = Client(account_sid, auth_token)
|
|
|
|
# Email Account Setup
|
|
smtp_server = 'in-v3.mailjet.com'
|
|
smtp_port = 587
|
|
|
|
|
|
def sendText(contact, clean):
|
|
|
|
if clean is True:
|
|
cleanMsg = 'Feed the Hydroponics. It also needs to be cleaned today'
|
|
else:
|
|
cleanMsg = 'Feed the Hydroponics.'
|
|
|
|
message = client.messages.create(
|
|
messaging_service_sid='MG864145600a43493122488250262ccbc9',
|
|
body=cleanMsg,
|
|
to=contact
|
|
)
|
|
return
|
|
|
|
|
|
def sendEmail(contact, clean):
|
|
|
|
from_addr = 'Hydro@dandembinski.com'
|
|
|
|
smtp = SMTP()
|
|
smtp.connect(smtp_server, smtp_port)
|
|
smtp.login('bef546c3019739fff8a2dbbfc26ec74a', 'dbe2b63a3f1fa5e4f00217c2784a8055')
|
|
|
|
if clean is True:
|
|
cleanMsg = 'Feed the Hydroponics. It also needs to be cleaned today'
|
|
else:
|
|
cleanMsg = 'Feed the Hydroponics.'
|
|
|
|
bodyHTML = MIMEText(cleanMsg, "html")
|
|
|
|
msg = MIMEMultipart()
|
|
msg['Subject'] = 'Feed Hydroponics'
|
|
msg['To'] = contact
|
|
msg['From'] = from_addr
|
|
|
|
msg.add_header('Content-Type', 'text/html')
|
|
msg.attach(bodyHTML)
|
|
|
|
try:
|
|
smtp.send_message(msg)
|
|
except Exception as e:
|
|
print(e)
|
|
return
|