def send(self, recipient, subject, message):
if self.configured is False:<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>self.smtp = smtplib.SMTP(<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:host>"],<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:port>"]<EOL>)<EOL>self.smtp.connect(<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:host>"],<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:port>"]<EOL>)<EOL>if self.application.config["<STR_LIT>"]["<STR_LIT>"]:<EOL><INDENT>self.smtp.starttls()<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>if hasattr(self, "<STR_LIT>") and self.smtp is not None:<EOL><INDENT>self.smtp.quit()<EOL><DEDENT>self.log.warn(<EOL>"<STR_LIT>",<EOL>error=str(e)<EOL>)<EOL>return False<EOL><DEDENT>if len(self.application.config["<STR_LIT>"]["<STR_LIT:username>"]) > <NUM_LIT:0>:<EOL><INDENT>try:<EOL><INDENT>self.smtp.login(<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:username>"],<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:password>"]<EOL>)<EOL><DEDENT>except Exception as e:<EOL><INDENT>if hasattr(self, "<STR_LIT>") and self.smtp is not None:<EOL><INDENT>self.smtp.quit()<EOL><DEDENT>self.log.warn(<EOL>"<STR_LIT>",<EOL>error=str(e)<EOL>)<EOL>return False<EOL><DEDENT><DEDENT>messageHeaders = []<EOL>messageHeaders.append("<STR_LIT>".format(<EOL>self.application.config["<STR_LIT>"]["<STR_LIT:name>"],<EOL>self.application.config["<STR_LIT>"]["<STR_LIT>"]<EOL>))<EOL>if len(recipient) == <NUM_LIT:2>:<EOL><INDENT>messageHeaders.append("<STR_LIT>".format(<EOL>recipient[<NUM_LIT:1>],<EOL>recipient[<NUM_LIT:0>]<EOL>))<EOL><DEDENT>else:<EOL><INDENT>messageHeaders.append("<STR_LIT>".format(<EOL>recipient[<NUM_LIT:0>]<EOL>))<EOL><DEDENT>messageHeaders.append("<STR_LIT>")<EOL>messageHeaders.append("<STR_LIT>")<EOL>messageHeaders.append("<STR_LIT>".format(subject))<EOL>emailContents = "<STR_LIT>"<EOL>for messageHeaderLine in messageHeaders:<EOL><INDENT>if len(emailContents) == <NUM_LIT:0>:<EOL><INDENT>emailContents = messageHeaderLine<EOL><DEDENT>else:<EOL><INDENT>emailContents = "<STR_LIT>".format(<EOL>emailContents,<EOL>messageHeaderLine<EOL>)<EOL><DEDENT><DEDENT>emailContents = "<STR_LIT>".format(<EOL>emailContents,<EOL>message<EOL>)<EOL>try:<EOL><INDENT>self.smtp.sendmail(<EOL>self.application.config["<STR_LIT>"]["<STR_LIT>"],<EOL>[recipient[<NUM_LIT:0>]],<EOL>emailContents<EOL>)<EOL><DEDENT>except smtplib.SMTPRecipientsRefused as e:<EOL><INDENT>if hasattr(self, "<STR_LIT>") and self.smtp is not None:<EOL><INDENT>self.smtp.quit()<EOL><DEDENT>self.log.warn(<EOL>"<STR_LIT>""<STR_LIT>",<EOL>recipients=recipient,<EOL>error=str(e)<EOL>)<EOL>return False<EOL><DEDENT>except smtplib.SMTPSenderRefused as e:<EOL><INDENT>if hasattr(self, "<STR_LIT>") and self.smtp is not None:<EOL><INDENT>self.smtp.quit()<EOL><DEDENT>self.log.warn(<EOL>"<STR_LIT>""<STR_LIT>",<EOL>sender=self.application.config["<STR_LIT>"]["<STR_LIT>"],<EOL>error=str(e)<EOL>)<EOL>return False<EOL><DEDENT>except Exception as e:<EOL><INDENT>if hasattr(self, "<STR_LIT>") and self.smtp is not None:<EOL><INDENT>self.smtp.quit()<EOL><DEDENT>self.log.warn(<EOL>"<STR_LIT>",<EOL>error=str(e)<EOL>)<EOL>return False<EOL><DEDENT>return True<EOL>
Sends an email using the SMTP connection.

:param recipient: <tuple> recipient's email address as the first element and their name as an optional second
                    element
:param subject: <str> mail subject
:param message: <str> mail content (as HTML markup)
:return: <bool> True if mail was sent successfully, False otherwise