class SendMail:
def __init__(self,smtpadd,fromadd,toadd):
self.Smtpadd = smtpadd
self.Fromadd = fromadd
self.Toadd = toadd
def Login_Smtp(self,password):
self.smtp = smtplib.SMTP()
self.smtp.connect(self.Smtpadd,25)
self.smtp.login(self.Fromadd,password)
def Send_msg(self,subject,body):
body = base64.b64encode(body)
msg = 'From:%s\nTo:%s\nSubject:%s\nContent-Type:text/html\nContent-Transfer-Encoding:base64\n\n%s'%(
self.Fromadd,self.Toadd,subject,body)
self.smtp.sendmail(self.Fromadd,self.Toadd,msg)
def Smtp_Logout(self):
self.smtp.quit()