'Connect/authenticate to SMTP Server.'

def connect(self):

    if (self.encryption == 'tls'):
        mail = smtplib.SMTP_SSL(self._server, self._port, timeout=self._timeout)
    else:
        mail = smtplib.SMTP(self._server, self._port, timeout=self._timeout)
    mail.set_debuglevel(self.debug)
    mail.ehlo_or_helo_if_needed()
    if (self.encryption == 'starttls'):
        mail.starttls()
        mail.ehlo()
    if (self.username and self.password):
        mail.login(self.username, self.password)
    return mail
