28 lines
683 B
Python
28 lines
683 B
Python
import smtplib
|
|
from email.mime.text import MIMEText
|
|
|
|
class Mailer():
|
|
def __init__(self, google_owner, google_code):
|
|
self.google_owner = google_owner
|
|
self.google_code = google_code
|
|
|
|
def send(self, sender, receiver, subject, msg):
|
|
msg = MIMEText(msg, 'html')
|
|
msg['Subject'] = subject
|
|
msg['From'] = sender
|
|
msg['To'] = receiver
|
|
|
|
smtp = smtplib.SMTP('smtp.gmail.com', 587)
|
|
smtp.ehlo()
|
|
smtp.starttls()
|
|
smtp.login(self.google_owner, self.google_code)
|
|
|
|
status = smtp.send_message(msg)
|
|
smtp.quit()
|
|
|
|
if status == {}:
|
|
return True
|
|
else:
|
|
return False
|
|
|