Initialize the handler. Initialize the instance with the from and to addresses and subject line of the email. To specify a non-standard SMTP port, use the (host, port) tuple format for the mailhost argument. To specify authentication credentials, supply a (u
(self, mailhost, fromaddr, toaddrs, subject,
credentials=None, secure=None, timeout=5.0)
| 1034 | A handler class which sends an SMTP email for each logging event. |
| 1035 | """ |
| 1036 | def __init__(self, mailhost, fromaddr, toaddrs, subject, |
| 1037 | credentials=None, secure=None, timeout=5.0): |
| 1038 | """ |
| 1039 | Initialize the handler. |
| 1040 | |
| 1041 | Initialize the instance with the from and to addresses and subject |
| 1042 | line of the email. To specify a non-standard SMTP port, use the |
| 1043 | (host, port) tuple format for the mailhost argument. To specify |
| 1044 | authentication credentials, supply a (username, password) tuple |
| 1045 | for the credentials argument. To specify the use of a secure |
| 1046 | protocol (TLS), pass in a tuple for the secure argument. This will |
| 1047 | only be used when authentication credentials are supplied. The tuple |
| 1048 | will be either an empty tuple, or a single-value tuple with the name |
| 1049 | of a keyfile, or a 2-value tuple with the names of the keyfile and |
| 1050 | certificate file. (This tuple is passed to the |
| 1051 | `ssl.SSLContext.load_cert_chain` method). |
| 1052 | A timeout in seconds can be specified for the SMTP connection (the |
| 1053 | default is one second). |
| 1054 | """ |
| 1055 | logging.Handler.__init__(self) |
| 1056 | if isinstance(mailhost, (list, tuple)): |
| 1057 | self.mailhost, self.mailport = mailhost |
| 1058 | else: |
| 1059 | self.mailhost, self.mailport = mailhost, None |
| 1060 | if isinstance(credentials, (list, tuple)): |
| 1061 | self.username, self.password = credentials |
| 1062 | else: |
| 1063 | self.username = None |
| 1064 | self.fromaddr = fromaddr |
| 1065 | if isinstance(toaddrs, str): |
| 1066 | toaddrs = [toaddrs] |
| 1067 | self.toaddrs = toaddrs |
| 1068 | self.subject = subject |
| 1069 | self.secure = secure |
| 1070 | self.timeout = timeout |
| 1071 | |
| 1072 | def getSubject(self, record): |
| 1073 | """ |
no outgoing calls
no test coverage detected