'Returns a new SMTP connection to the give SMTP server, authenticated
with ``user`` and ``password`` if provided, and encrypted as requested
by the ``encryption`` parameter.
:param host: host or IP of SMTP server to connect to
:param int port: SMTP port to connect to
:param user: optional username to authenticate with
:param password: optional password to authenticate with
:param string encryption: optional, ``\'ssl\'`` | ``\'starttls\'``
:param bool smtp_debug: toggle debugging of SMTP sessions (all i/o
will be output in logs)'

def connect(self, host, port, user=None, password=None, encryption=False, smtp_debug=False):

    if (encryption == 'ssl'):
        if (not ('SMTP_SSL' in smtplib.__all__)):
            raise UserError(_('Your    OpenERP    Server    does    not    support    SMTP-over-SSL.    You    could    use    STARTTLS    instead.If    SSL    is    needed,    an    upgrade    to    Python    2.6    on    the    server-side    should    do    the    trick.'))
        connection = smtplib.SMTP_SSL(host, port)
    else:
        connection = smtplib.SMTP(host, port)
    connection.set_debuglevel(smtp_debug)
    if (encryption == 'starttls'):
        connection.starttls()
    if user:
        user = ustr(user).encode('utf-8')
        password = ustr(password).encode('utf-8')
        connection.login(user, password)
    return connection
