-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendAlert.py
More file actions
31 lines (21 loc) · 848 Bytes
/
sendAlert.py
File metadata and controls
31 lines (21 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
import smtplib
import os
# Use sms gateway provided by mobile carrier:
# at&t: number@mms.att.net
# t-mobile: number@tmomail.net
# verizon: number@vtext.com
# sprint: number@page.nextel.com
def sendAlert(loginName, loginPass, sendTo, subject, text):
try:
message = 'Subject: %s\n\n%s' % (subject, text)
# Establish a secure session with gmail's outgoing SMTP server using your gmail account
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(loginName, loginPass)
# Send text message through SMS gateway of destination number
# server.sendmail( 'chris.pangburn@gmail.com (Chris)', '4044292504@tmomail.net', 'Test' )
server.sendmail(loginName, sendTo, message)
return "success"
except:
return "error"