Пример #1
0
def api_send_verification_email():
    """
    Send Verification Email to the `user_id` specified in the request

    :rtype: Response
    :return the success or failed in json format
    """
    passed, errors = check_email_config()
    if not passed:
        app.logger.warn(" ".join(errors))
        return utils.jsonify_error(
            {"message": "Unable to send email due to configuration errors."})

    user_id = utils.get_safe_int(request.form.get('user_id'))
    user = UserEntity.get_by_id(user_id)

    try:
        emails.send_verification_email(user)
        return utils.jsonify_success(
            {"message": "Verification email was sent."})
    except Exception as exc:
        details = "Connection config: {}/{}:{}".format(
            app.config['MAIL_USERNAME'],
            app.config['MAIL_SERVER'],
            app.config['MAIL_PORT'])
        app.logger.debug(details)
        return utils.jsonify_error(
            {"message": "Unable to send email due: {} {}".format(exc, details)})
Пример #2
0
def api_send_verification_email():
    """
    @TODO: Send Verification Email to user_id

    :rtype: Response
    :return the success or failed in json format
    """
    user_id = utils.get_safe_int(request.form.get("user_id"))
    user = UserEntity.get_by_id(user_id)

    try:
        emails.send_verification_email(user)
        return utils.jsonify_success({"message": "Verification email was sent."})
    except Exception as exc:
        details = "Connection config: {}/{}:{}".format(
            app.config["MAIL_USERNAME"], app.config["MAIL_SERVER"], app.config["MAIL_PORT"]
        )
        app.logger.debug(details)
        return utils.jsonify_error({"message": "Unable to send email due: {} {}".format(exc, details)})