Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- #
- # This is the application core, it only contains methods used by
- # both the graphical and text interfaces.
- #
- # TODO: See above.
- #
- import smtplib
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- import carrier
- class Core:
- def __init__(self, username, password):
- # code could be added here to auto load these from a file
- self.gmail_user = username
- self.gmail_pwd = password
- # Send one text to one number
- # TODO: send to multiple addresses
- def mail(self, to, text):
- msg = MIMEMultipart()
- msg['From'] = self.gmail_user
- msg['To'] = to
- msg.attach(MIMEText(text))
- mailServer = smtplib.SMTP("smtp.gmail.com", 587)
- mailServer.ehlo()
- mailServer.starttls()
- mailServer.ehlo()
- mailServer.login(self.gmail_user, self.gmail_pwd)
- mailServer.sendmail(self.gmail_user, to, msg.as_string())
- # Should be mailServer.quit(), but that crashes...
- mailServer.close()
- def texto(sendtoaddress, messagetext):
- numbersendlist = []
- for number in sendtoaddress:
- numbersendlist.append(carrier.carriercheck(number))
- for number in numbersendlist:
- core.mail(number, messagetext)
- texto(['1112223333'], 'hi. this better work.')
Advertisement
Add Comment
Please, Sign In to add comment