'get session'

@property
def sess(self):

    if self._sess:
        return self._sess
    if (not getattr(self, u'server')):
        err_msg = _(u'Email    Account    not    setup.    Please    create    a    new    Email    Account    from    Setup    >    Email    >    Email    Account')
        frappe.msgprint(err_msg)
        raise frappe.OutgoingEmailError(err_msg)
    try:
        if (self.use_tls and (not self.port)):
            self.port = 587
        self._sess = smtplib.SMTP((self.server or u'').encode(u'utf-8'), (cint(self.port) or None))
        if (not self._sess):
            err_msg = _(u'Could    not    connect    to    outgoing    email    server')
            frappe.msgprint(err_msg)
            raise frappe.OutgoingEmailError(err_msg)
        if self.use_tls:
            self._sess.ehlo()
            self._sess.starttls()
            self._sess.ehlo()
        if (self.login and self.password):
            ret = self._sess.login((self.login or u'').encode(u'utf-8'), (self.password or u'').encode(u'utf-8'))
            if (ret[0] != 235):
                frappe.msgprint(ret[1])
                raise frappe.OutgoingEmailError(ret[1])
        return self._sess
    except _socket.error as e:
        frappe.msgprint(_(u'Invalid    Outgoing    Mail    Server    or    Port'))
        traceback = sys.exc_info()[2]
        raise_(frappe.ValidationError, e, traceback)
    except smtplib.SMTPAuthenticationError as e:
        frappe.msgprint(_(u'Invalid    login    or    password'))
        traceback = sys.exc_info()[2]
        raise_(frappe.ValidationError, e, traceback)
    except smtplib.SMTPException:
        frappe.msgprint(_(u'Unable    to    send    emails    at    this    time'))
        raise
