def setup_smtp_object(smtp, user, passwd):
    """
    Helper function.  Set up an `smtplib.SMTP` object for use with CAT-SOOP,
    enabling TLS if possible and logging in a user if information is specified.

    **Parameters**:

    * `smtp`: the `smtplib.SMTP` object to configure
    * `user`: the username to use when logging in
    * `password`: the password to use when logging in

    **Returns:** the same `smtplib.SMTP` object that was passed in, after
    configuring it.
    """
    smtp.set_debuglevel(False)
    smtp.ehlo()
    if user is not None and passwd is not None:
        if smtp.has_extn('STARTTLS'):
            smtp.starttls()
            smtp.ehlo()
        smtp.login(user, passwd)
    return smtp
