Skip to content

Instantly share code, notes, and snippets.

@mkowoods
Last active August 29, 2015 14:10
Show Gist options
  • Save mkowoods/903c140767483b702f77 to your computer and use it in GitHub Desktop.
Save mkowoods/903c140767483b702f77 to your computer and use it in GitHub Desktop.
email blast messaging solution
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 20 18:48:28 2014
@author: mwoods
code is based on textbelt by Ian Webster
https://github.com/typpo/textbelt/tree/master/lib
"""
import smtplib
FROM_EMAIL = None
SMTP_SERVER = 'localhost'
class SendText:
def __init__(self, phone, message, region = 'US'):
self.server = 'localhost' #need to configure to actual server
self.from_email = '[email protected]'
self.phone = phone
self.message = message
self.region = region
def send_message(self):
for car in PROVIDERS[self.region]:
receiver = car%self.phone
#print receiver
try:
smtp_server = smtplib.SMTP(self.server)
#additional code might be required to authenticate the smtp server such as un, pw
smtp_server.sendmail(self.from_email, receiver, self.message)
print "Successfully sent email"
except Exception as e:
print e, "Error: unable to send email to %s"%receiver
PROVIDERS = {
'US': [
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]'
],
'CA': [
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
],
'ROW': [
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
'%[email protected]',
#'[email protected] (put the number in the subject line)',
#'[email protected]',
],
}
if __name__ == "__main__":
S = SendText('55555555555', 'test')
S.send_message()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment