forked from birolemekli/tcdd-bilet-yer-kontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mail.py
46 lines (39 loc) · 1.46 KB
/
Mail.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# coding=utf-8
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
import smtplib
class Mail:
def __init__(self,mail_to,subject):
self.__smtp_host="smtp.x.com" # ie : smtp.gmail.com
self.__mail_from="your mail" #ie : [email protected]
self.__mail_from_password="your password" # ie : 123456
self.mail_to=mail_to
self.subject=subject
def sendMail(self,timee):
try:
msg = MIMEMultipart()
password = self.__mail_from_password
msg['From'] =self.__mail_from
msg['To'] = self.mail_to
msg['Subject'] = self.subject
msg.attach(MIMEText(self.subject))
msg.attach(MIMEText(timee))
server = smtplib.SMTP(self.__smtp_host)
server.starttls()
server.login(msg['From'], password)
server.sendmail(msg['From'], msg["To"].split(","), msg.as_string())
print ('Mail gonderildi...')
except Exception as e:
print(e)
print ('Mail göndermede bir sorun meydana geldi')
def getHost(self):
return self.__smtp_host
def setHost(self,stmpHost):
self.__smtp_host=stmpHost
def getFrom(self):
return self.__mail_from
def setFrom(self,mailFrom):
self.__mail_from=mailFrom
def setFromPassword(self,mailFromPassword):
self.__mail_from_password=mailFromPassword