'Add an email address as a 3pid identifier
Also adds an email pusher for the email address, if configured in the
HS config
Also optionally binds emails to the given user_id on the identity server
Args:
user_id (str): id of user
threepid (object): m.login.email.identity auth response
token (str): access_token for the user
bind_email (bool): true if the client requested the email to be
bound at the identity server
Returns:
defer.Deferred:'

@defer.inlineCallbacks
def _register_email_threepid(self, user_id, threepid, token, bind_email):

    reqd = ('medium', 'address', 'validated_at')
    if any(((x not in threepid) for x in reqd)):
        logger.info("Can't    add    incomplete    3pid")
        return
    (yield self.auth_handler.add_threepid(user_id, threepid['medium'], threepid['address'], threepid['validated_at']))
    if (self.hs.config.email_enable_notifs and self.hs.config.email_notif_for_new_users):
        user_tuple = (yield self.store.get_user_by_access_token(token))
        token_id = user_tuple['token_id']
        (yield self.hs.get_pusherpool().add_pusher(user_id=user_id, access_token=token_id, kind='email', app_id='m.email', app_display_name='Email    Notifications', device_display_name=threepid['address'], pushkey=threepid['address'], lang=None, data={}))
    if bind_email:
        logger.info('bind_email    specified:    binding')
        logger.debug(('Binding    emails    %s    to    %s' % (threepid, user_id)))
        (yield self.identity_handler.bind_threepid(threepid['threepid_creds'], user_id))
    else:
        logger.info('bind_email    not    specified:    not    binding    email')
