-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalert.py
More file actions
24 lines (20 loc) · 674 Bytes
/
alert.py
File metadata and controls
24 lines (20 loc) · 674 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
import socket
import smtplib
class EmailSender:
def send_message(self, users, message):
try:
smtpobj = smtplib.SMTP('localhost', 1025)
smtpobj.sendmail('user', users, message)
smtpobj.quit()
return True
except socket.error:
return False
def say_in_email(self, name, recipient):
hellomessage = self.hello(name) + '. You are ' + self.hello(name)
message = 'Ah ' + hellomessage
if self.send_message(recipient, message):
return message
else:
return 'Error in sending email'
def hello(self, name):
return "hello %s" % name