mirror of https://github.com/fail2ban/fail2ban
- Added SMTP authentification support
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@229 a942ae1a-1317-0410-a47c-b1dcaea8d6050.6
parent
85f1d74d85
commit
6386c9e580
|
@ -44,6 +44,16 @@ class Mail:
|
||||||
""" Set from: address
|
""" Set from: address
|
||||||
"""
|
"""
|
||||||
self.fromAddr = fromAddr
|
self.fromAddr = fromAddr
|
||||||
|
|
||||||
|
def setUser(self, user):
|
||||||
|
""" Set smtpuser
|
||||||
|
"""
|
||||||
|
self.user = user
|
||||||
|
|
||||||
|
def setPassword(self, password):
|
||||||
|
""" Set smtppassword
|
||||||
|
"""
|
||||||
|
self.password = password
|
||||||
|
|
||||||
def setToAddr(self, toAddr):
|
def setToAddr(self, toAddr):
|
||||||
""" Set to: address
|
""" Set to: address
|
||||||
|
@ -69,6 +79,8 @@ class Mail:
|
||||||
try:
|
try:
|
||||||
server = smtplib.SMTP(self.host, self.port)
|
server = smtplib.SMTP(self.host, self.port)
|
||||||
#server.set_debuglevel(1)
|
#server.set_debuglevel(1)
|
||||||
|
if not self.user == '':
|
||||||
|
server.login(self.user, self.password)
|
||||||
server.sendmail(self.fromAddr, self.toAddr, mail)
|
server.sendmail(self.fromAddr, self.toAddr, mail)
|
||||||
logSys.debug("Email sent to " + `self.toAddr`)
|
logSys.debug("Email sent to " + `self.toAddr`)
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|
Loading…
Reference in New Issue