##// END OF EJS Templates
made auth type optional in constructor
marcink -
r1583:8e77c75b beta
parent child Browse files
Show More
@@ -36,11 +36,10 b' from email.utils import formatdate'
36 from email import encoders
36 from email import encoders
37
37
38
38
39
40 class SmtpMailer(object):
39 class SmtpMailer(object):
41 """SMTP mailer class
40 """SMTP mailer class
42
41
43 mailer = SmtpMailer(mail_from, user, passwd, mail_server,
42 mailer = SmtpMailer(mail_from, user, passwd, mail_server, smtp_auth
44 mail_port, ssl, tls)
43 mail_port, ssl, tls)
45 mailer.send(recipients, subject, body, attachment_files)
44 mailer.send(recipients, subject, body, attachment_files)
46
45
@@ -50,8 +49,8 b' class SmtpMailer(object):'
50
49
51 """
50 """
52
51
53 def __init__(self, mail_from, user, passwd, mail_server,smtp_auth,
52 def __init__(self, mail_from, user, passwd, mail_server, smtp_auth=None,
54 mail_port=None, ssl=False, tls=False, debug=False):
53 mail_port=None, ssl=False, tls=False, debug=False):
55
54
56 self.mail_from = mail_from
55 self.mail_from = mail_from
57 self.mail_server = mail_server
56 self.mail_server = mail_server
@@ -83,8 +82,8 b' class SmtpMailer(object):'
83 if self.auth:
82 if self.auth:
84 smtp_serv.esmtp_features["auth"] = self.auth
83 smtp_serv.esmtp_features["auth"] = self.auth
85
84
86 #if server requires authorization you must provide login and password
85 # if server requires authorization you must provide login and password
87 #but only if we have them
86 # but only if we have them
88 if self.user and self.passwd:
87 if self.user and self.passwd:
89 smtp_serv.login(self.user, self.passwd)
88 smtp_serv.login(self.user, self.passwd)
90
89
@@ -160,6 +159,7 b' class SmtpMailer(object):'
160 if isinstance(msg_file, str):
159 if isinstance(msg_file, str):
161 return open(msg_file, "rb").read()
160 return open(msg_file, "rb").read()
162 else:
161 else:
163 #just for safe seek to 0
162 # just for safe seek to 0
164 msg_file.seek(0)
163 msg_file.seek(0)
165 return msg_file.read()
164 return msg_file.read()
165
General Comments 0
You need to be logged in to leave comments. Login now