##// 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 36 from email import encoders
37 37
38 38
39
40 39 class SmtpMailer(object):
41 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 43 mail_port, ssl, tls)
45 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,
54 mail_port=None, ssl=False, tls=False, debug=False):
52 def __init__(self, mail_from, user, passwd, mail_server, smtp_auth=None,
53 mail_port=None, ssl=False, tls=False, debug=False):
55 54
56 55 self.mail_from = mail_from
57 56 self.mail_server = mail_server
@@ -83,8 +82,8 b' class SmtpMailer(object):'
83 82 if self.auth:
84 83 smtp_serv.esmtp_features["auth"] = self.auth
85 84
86 #if server requires authorization you must provide login and password
87 #but only if we have them
85 # if server requires authorization you must provide login and password
86 # but only if we have them
88 87 if self.user and self.passwd:
89 88 smtp_serv.login(self.user, self.passwd)
90 89
@@ -160,6 +159,7 b' class SmtpMailer(object):'
160 159 if isinstance(msg_file, str):
161 160 return open(msg_file, "rb").read()
162 161 else:
163 #just for safe seek to 0
162 # just for safe seek to 0
164 163 msg_file.seek(0)
165 164 return msg_file.read()
165
General Comments 0
You need to be logged in to leave comments. Login now