Send email confirmation to user
@param UserToken $userToken
@return int
348096
public function sendEmailConfirmation($userToken)
    {
        /** @var Mailer $mailer */
        /** @var Message $message */

        // modify view path to module views
        $mailer = Yii::$app->mailer;
        $oldViewPath = $mailer->viewPath;
        $mailer->viewPath = $this->module->emailViewPath;

        // send email
        $user = $this;
        $profile = $user->profile;
        $email = $userToken->data ?: $user->email;
        $subject = Yii::$app->id . " - " . Yii::t("user", "Email Confirmation");
        $result = $mailer->compose('confirmEmail', compact("subject", "user", "profile", "userToken"))
            ->setTo($email)
            ->setSubject($subject)
            ->send();

        // restore view path and return result
        $mailer->viewPath = $oldViewPath;
        return $result;
    }
500360
public function sendShopownerConfirmation(
        $recipient,
        ApiOrderInterface $apiOrder,
        ContactInterface $customerContact = null
    ) {
        if (!$this->sendEmailConfirmationToShopowner) {
            return false;
        }

        if (empty($recipient)) {
            // fallback address for shop-owner order confirmations
            $recipient = $this->confirmationRecipientEmailAddress;
        }

        return $this->sendConfirmationEmail(
            $recipient,
            $apiOrder,
            $this->templateShopownerConfirmationPath,
            $customerContact
        );
    }
77375
public function registerConfirm(\Swift_Mailer $mailer, EventDispatcherInterface $dispatcher, TranslatorInterface $translator, $token)
    {
        // Get Doctrine
        $em = $this->getDoctrine()->getManager();

        // Find User
        $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['confirmationToken' => $token]);
        if (null === $user) {
            throw $this->createNotFoundException(sprintf($translator->trans('security.token_notfound'), $token));
        }

        // Enabled User
        $user->setConfirmationToken(null);
        $user->setEnabled(true);

        // Send Welcome
        if ($this->getParameter('pd_user.welcome_email')) {
            $this->sendEmail($user, $mailer, 'Registration', 'Welcome', 'Welcome');
        }

        // Update User
        $em->persist($user);
        $em->flush();

        // Dispatch Register Event
        if ($response = $dispatcher->dispatch(UserEvent::REGISTER_CONFIRM, new UserEvent($user))->getResponse()) {
            return $response;
        }

        // Register Success
        return $this->render($this->getParameter('pd_user.template_path') . '/Registration/registerSuccess.html.twig', [
            'user' => $user,
        ]);
    }
188256
protected function sendReactivationEmail(User $user)
    {
        $forum = Podium::getInstance()->podiumConfig->get('name');
        $email = Content::fill(Content::EMAIL_REACTIVATION);
        if ($email !== false) {
            $link = Url::to(['account/activate', 'token' => $user->activation_token], true);
            return Email::queue(
                $user->email,
                str_replace('{forum}', $forum, $email->topic),
                str_replace('{forum}', $forum, str_replace('{link}',
                    Html::a($link, $link), $email->content)),
                !empty($user->id) ? $user->id : null
            );
        }
        return false;
    }
772207
public function sendWelcomeMessage(User $user, Token $token = null)
    {
        $mailVars = [
            '{token}' => $token->url,
            '{legal_link}' => Url::toRoute([
                '/legal/default/view',
                'legalId' => Legal::findOne(['key' => 'buyers'])->id,
                'langId' => Language::getCurrent()->id
            ], true)
        ];

        /**
         * @var $mailTemplate Template
         */
        $mailTemplate = \Yii::$app->get('emailTemplates')
            ->getTemplate('welcome', Language::getCurrent()->id);
        $mailTemplate->parseSubject($mailVars);
        $mailTemplate->parseBody($mailVars);

        return \Yii::$app->shopMailer->compose('mail-body', ['bodyContent' => $mailTemplate->getBody()])
            ->setFrom([\Yii::$app->shopMailer->transport->getUsername() => \Yii::$app->name ?? Url::to(['/'], true)])
            ->setTo($user->email)
            ->setSubject($mailTemplate->getSubject())
            ->send();
    }
955923
public function setEmailToken($userid = null)
	{
		$this->debug->groupCollapsed(__METHOD__);
		if (!isset($userid)) {
			$userid = $this->userid;
		}
		$this->debug->log('userid', $userid);
		$token = $this->genToken();
		/*
			remove any existing token
		*/
		$where = array( 'userid' => $userid);
		$response = $this->db->rowMan('email_tokens', null, $where);
		/*
			store hashed token in db
		*/
		$vals = array(
			'userid'		=> $userid,
			'token_hash'	=> sha1($token),
		);
		$response = $this->db->rowMan('email_tokens', $vals);
		$this->log('pwForgotTokenGen', $userid);	// @todo forgot_token_gen??
		$return = $response !== false
			? base64_encode($token)
			: false;
		$this->debug->groupEnd();
		return $return;
	}
1026525
public function updateUserToken(UserTokenUpdateStruct $userTokenUpdateStruct)
    {
        try {
            return $this->innerGateway->updateUserToken($userTokenUpdateStruct);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1329465
public static function confirm(string $token, string $email)
    {
        $user = static::where('confirmation_token', $token)
            ->where('verified', false)
            ->where('email', $email)
            ->firstOrFail();

        $user->verified = true;
        $user->save();

        return $user;
    }
1103374
private function sendEmailConfirmationLink($user, $keySuffix)
    {
        $login = $user['login'];
        $email = $user['email'];

        // construct a password reset token from user information
        $resetToken = $this->generatePasswordResetToken($user, $keySuffix);

        $confirmPasswordModule = $this->confirmPasswordModule;
        $confirmPasswordAction = $this->confirmPasswordAction;

        $ip = IP::getIpFromHeader();
        $url = Url::getCurrentUrlWithoutQueryString()
            . "?module=$confirmPasswordModule&action=$confirmPasswordAction&login=" . urlencode($login)
            . "&resetToken=" . urlencode($resetToken);

        // send email with new password
        $mail = new Mail();
        $mail->addTo($email, $login);
        $mail->setSubject(Piwik::translate('Login_MailTopicPasswordChange'));
        $bodyText = '<p>' . str_replace(
                "\n\n",
                "</p><p>",
                Piwik::translate('Login_MailPasswordChangeBody2', [Common::sanitizeInputValue($login), $ip, $url])
            ) . "</p>";
        $mail->setWrappedHtmlBody($bodyText);

        $mail->setFrom($this->emailFromAddress, $this->emailFromName);

        $replytoEmailName = Config::getInstance()->General['login_password_recovery_replyto_email_name'];
        $replytoEmailAddress = Config::getInstance()->General['login_password_recovery_replyto_email_address'];
        $mail->setReplyTo($replytoEmailAddress, $replytoEmailName);

        @$mail->send();
    }
348002
function user_confirm($username, $confirmsecret) {
        global $DB;

        $user = get_complete_user_data('username', $username);

        if (!empty($user)) {
            if ($user->auth != $this->authtype) {
                return AUTH_CONFIRM_ERROR;

            } else if ($user->secret == $confirmsecret && $user->confirmed) {
                return AUTH_CONFIRM_ALREADY;

            } else if ($user->secret == $confirmsecret) {   // They have provided the secret key to get in
                if (!$this->user_activate($username)) {
                    return AUTH_CONFIRM_FAIL;
                }
                $user->confirmed = 1;
                user_update_user($user, false);
                return AUTH_CONFIRM_OK;
            }
        } else {
            return AUTH_CONFIRM_ERROR;
        }
    }
1085238
public function sendEmail()
    {
        if (!$this->validate()) {
            return false;
        }

        /** @var \amnah\yii2\user\models\UserToken $userToken */
        $user = $this->getUser();
        $userToken = $this->module->model("UserToken");

        // calculate type based on user status
        if ($user->status == $user::STATUS_INACTIVE) {
            $type = $userToken::TYPE_EMAIL_ACTIVATE;
        } //elseif ($user->status == $user::STATUS_UNCONFIRMED_EMAIL) {
        else {
            $type = $userToken::TYPE_EMAIL_CHANGE;
        }

        // generate userToken and send email confirmation
        $userToken = $userToken::generate($user->id, $type);
        return $user->sendEmailConfirmation($userToken);
    }
324311
private function getUniqueToken($startToken)
    {
        try {
            $this->getUserRepository()->findUserByToken($startToken);
        } catch (NoResultException $ex) {
            return $startToken;
        }

        return $this->getUniqueToken($this->getTokenGenerator()->generateToken());
    }
102262
public function register($user, $token)
    {
        return $this->to($user['email'])
            ->subject('Please confirm your email')
            ->template('Users.welcome')
            ->layout(false)
            ->set([
                'username' => $user['username'],
                'token' => $token,
            ])
            ->emailFormat('html');
    }
933365
public function exists(Contracts\RequiresEmailVerification $user, $token)
    {
        $email = $user->getEmailForVerification();

        $token = (array) $this->getTable()->where('email', $email)->where('token', $token)->first();

        return $token && !$this->tokenExpired($token);
    }
718644
private function getUser(TokenInterface $authenticationToken)
    {
        $user = $authenticationToken->getUser();

        if (is_string($user)) {
            return $user;
        } elseif (method_exists($user, 'getAPIUser')) {
            return $user->getAPIUser()->id;
        }

        return $authenticationToken->getUsername();
    }
1050020
public function validateAccountConfirmationToken($username, $token)
    {
        $this->username = $username;

        if ($this->getMeta()->confirmationToken == $token) {
            $this->getMeta()->confirmed = true;
            $this->getMeta()->confirmationToken = '';
            $this->getMeta()->save();

            return true;
        }

        return false;
    }
519283
def confirm_email_view(self, token):
        
        # Verify token
        data_items = self.token_manager.verify_token(
            token,
            self.USER_CONFIRM_EMAIL_EXPIRATION)

        # Retrieve user, user_email by ID
        user = None
        user_email = None
        if data_items:
            user, user_email = self.db_manager.get_user_and_user_email_by_id(data_items[0])

        if not user or not user_email:
            flash(_('Invalid confirmation token.'), 'error')
            return redirect(url_for('user.login'))

        # Set UserEmail.email_confirmed_at
        user_email.email_confirmed_at=datetime.utcnow()
        self.db_manager.save_user_and_user_email(user, user_email)
        self.db_manager.commit()

        # Send confirmed_email signal
        signals.user_confirmed_email.send(current_app._get_current_object(), user=user)

        # Flash a system message
        flash(_('Your email has been confirmed.'), 'success')

        # Auto-login after confirm or redirect to login page
        safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_CONFIRM_ENDPOINT)
        if self.USER_AUTO_LOGIN_AFTER_CONFIRM:
            return self._do_login_user(user, safe_next_url)  # auto-login
        else:
            return redirect(url_for('user.login') + '?next=' + quote(safe_next_url))