send a message to the email of the user

@return Reponse
499487
public function sendToEmail(Request $request, UserMailer $userMailer)
    {
        $this->validate($request, [
            'email' => 'required|email'
        ]);
        $request = $request->only('email');
        $request['token'] = str_random(40);
        $this->resetPasswordRepo->create($request);
        $userMailer->sendResetPasswordEmailTo($request);
        return redirect()->route('core::home');
    }
580358
public function _sendMail()
    {
        $date = gmdate('D, d M Y H:i:s O');

        //Send the request
        $client = new Zend_Http_Client($this->_host);
        $client->setMethod(Zend_Http_Client::POST);
        $client->setHeaders(array(
            'Date' => $date,
            'X-Amzn-Authorization' => $this->_buildAuthKey($date)
        ));
        $client->setEncType('application/x-www-form-urlencoded');

        //Build the parameters
        $params = array(
            'Action' => 'SendRawEmail',
            'Source' => $this->_mail->getFrom(),
            'RawMessage.Data' => base64_encode(sprintf("%s\n%s\n", $this->header, $this->body))
        );

        $recipients = explode(',', $this->recipients);
        while(list($index, $recipient) = each($recipients)){
            $params[sprintf('Destination.ToAddresses.member.%d', $index + 1)] = $recipient;
        }

        $client->resetParameters();
        $client->setParameterPost($params);
        $response = $client->request(Zend_Http_Client::POST);

        if($response->getStatus() != 200){
            throw new Exception($response->getBody());
        }
    }
715091
public function checkEmailAction()
    {
        $session = $this->container->get('session');
        $email = $session->get(static::SESSION_EMAIL);
        $session->remove(static::SESSION_EMAIL);

        if (empty($email)) {
            // the user does not come from the sendEmail action
            return new RedirectResponse($this->container->get('router')->generate('sonata_user_resetting_request'));
        }

        $template = $this->container->get('bruery_core.template_loader')->getTemplates();
        return $this->container->get('templating')->renderResponse($template['bruery_user.template.resetting.check_email'], array(
            'email' => $email,
        ));
    }
1240792
public function sendUpdateEmail()
    {
        // Prepare data for mail
        $admin = app('decoy.user');
        $email = [
            'editor_first_name' => $admin->first_name,
            'editor_last_name' => $admin->last_name,
            'first_name' =>request('first_name'),
            'last_name' =>request('last_name'),
            'email' => request('email'),
            'password' =>request('password'),
            'url' => Request::root().'/'.Config::get('decoy.core.dir'),
            'root' => Request::root(),
        ];

        // Send the email
        Mail::send('decoy::emails.update', $email, function ($m) use ($email) {
            $m->to($email['email'], $email['first_name'].' '.$email['last_name']);
            $m->subject('Your '.Decoy::site().' admin account info has been updated');
        });
    }
593184
protected function buildEmail()
    {
        $email = $this->getEmailObject();

        $email->setSubject($this->getSubject());
        $email->setRecipient($this->getRecipient());
        $email->setFrom($this->getSender());
        $email->setBody($this->getBody());

        return $email;
    }
1362182
public function sendAction()
    {
        $contactForm = $this->createForm(FrontForm::CONTACT);
        
        try {
            $form = $this->validateForm($contactForm);

            $event = new ContactEvent($form);

            $this->dispatch(TheliaEvents::CONTACT_SUBMIT, $event);

            $this->getMailer()->sendSimpleEmailMessage(
                [ ConfigQuery::getStoreEmail() => $event->getName() ],
                [ ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName() ],
                $event->getSubject(),
                '',
                $event->getMessage(),
                [],
                [],
                [ $event->getEmail() => $event->getName() ]
            );

            if ($contactForm->hasSuccessUrl()) {
                return $this->generateSuccessRedirect($contactForm);
            }
            
            return $this->generateRedirectFromRoute('contact.success');
            
        } catch (FormValidationException $e) {
            $error_message = $e->getMessage();
        }
        
        Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message));
        
        $contactForm->setErrorMessage($error_message);
        
        $this->getParserContext()
            ->addForm($contactForm)
            ->setGeneralError($error_message)
        ;
        
        // Redirect to error URL if defined
        if ($contactForm->hasErrorUrl()) {
            return $this->generateErrorRedirect($contactForm);
        }
    }
238365
public function sendDigestMails()
    {
        $subscriptionRepository = $this->entityManager->getRepository('PhlexibleMessageBundle:Subscription');
        $subscriptions = $subscriptionRepository->findByHandler('digest');

        $digests = [];
        foreach ($subscriptions as $subscription) {
            $filter = $this->filterManager->find($subscription->getFilterId());
            if (!$filter) {
                continue;
            }

            $user = $this->userManager->find($subscription->getUserId());
            if (!$user || !$user->getEmail()) {
                continue;
            }

            $lastSend = $subscription->getAttribute('lastSend', null);
            if (!$lastSend) {
                $lastSend = new \DateTime();
                $lastSend = $lastSend->sub(new \DateInterval('P30D'));
            } else {
                $lastSend = new \DateTime($lastSend);
            }

            $criteria = new Criteria([$filter->getCriteria()], Criteria::MODE_AND);
            $criteria->dateFrom($lastSend);
            $messages = $this->messageRepository->findByCriteria($criteria);
            if (!count($messages)) {
                continue;
            }

            if ($this->mailer->sendDigestMail($user, $messages)) {
                $digests[] = ['filter' => $filter->getTitle(), 'to' => $user->getEmail(), 'status' => 'ok'];
                $subscription->setAttribute('lastSend', date('Y-m-d H:i:s'));
                $this->subscriptionRepository->save($subscription);
            } else {
                $digests[] = ['filter' => $filter->getTitle(), 'to' => $user->getEmail(), 'status' => 'failed'];
            }
        }

        if (count($digests)) {
            $message = Message::create(
                count($digests).' digest mail(s) sent.',
                'Status: '.PHP_EOL.print_r($digests, true),
                Message::PRIORITY_NORMAL,
                null,
                'ROLE_MESSAGES',
                'cli'
            );
            $this->messageService->post($message);
        }

        return $digests;
    }
701979
protected function _send()
	{
		// Build the message
		$message = $this->build_message();

		// Open a connection
		$return_path = ($this->config['return_path'] !== false) ? $this->config['return_path'] : $this->config['from']['email'];
		$handle = @popen($this->config['sendmail_path'] . " -oi -f ".$return_path." -t", 'w');

		// No connection?
		if(! is_resource($handle))
		{
			throw new \SendmailConnectionException('Could not open a sendmail connection at: '.$this->config['sendmail_path']);
		}

		// Send the headers
		fputs($handle, $message['header']);

		// Send the body
		fputs($handle, $message['body']);

		if(pclose($handle) === -1)
		{
			throw new \SendmailFailedException('Failed sending email through sendmail.');
		}

		return true;
	}
316213
public function sendReservation()
    {
        // Get the mail sender or fallback to the admin email
        if (($from = self::config()->get('mail_sender')) && empty($from)) {
            $from = Config::inst()->get('Email', 'admin_email');
        }

        // Create the email with given template and reservation data
        $email = new Email();
        $email->setSubject(_t(
            'ReservationMail.TITLE',
            'Your order at {sitename}',
            null,
            array(
                'sitename' => SiteConfig::current_site_config()->Title
            )
        ));
        $email->setFrom($from);
        $email->setTo($this->MainContact()->Email);
        $email->setTemplate('ReservationMail');
        $email->populateTemplate($this);
        $this->extend('updateReservationMail', $email);
        return $email->send();
    }
447202
protected function _send()
	{
		$message = $this->build_message(true);

		if(empty($this->config['smtp']['host']) or empty($this->config['smtp']['port']))
		{
			throw new \FuelException('Must supply a SMTP host and port, none given.');
		}

		// Use authentication?
		$authenticate = (empty($this->smtp_connection) and ! empty($this->config['smtp']['username']) and ! empty($this->config['smtp']['password']));

		// Connect
		$this->smtp_connect();

		// Authenticate when needed
		$authenticate and $this->smtp_authenticate();

		// Set from
		$this->smtp_send('MAIL FROM:<'.$this->config['from']['email'].'>', 250);

		foreach(array('to', 'cc', 'bcc') as $list)
		{
			foreach($this->{$list} as $recipient)
			{
				$this->smtp_send('RCPT TO:<'.$recipient['email'].'>', array(250, 251));
			}
		}

		// Prepare for data sending
		$this->smtp_send('DATA', 354);

		$lines = explode($this->config['newline'], $message['header'].preg_replace('/^\./m', '..$1', $message['body']));

		foreach($lines as $line)
		{
			if(substr($line, 0, 1) === '.')
			{
				$line = '.'.$line;
			}

			fputs($this->smtp_connection, $line.$this->config['newline']);
		}

		// Finish the message
		$this->smtp_send('.', 250);

		// Close the connection if we're not using pipelining
		$this->pipelining or $this->smtp_disconnect();

		return true;
	}
361239
public function sendEmail()
    {
        $mandrill = new Mandrill(Yii::$app->params['mandrill']['key']);
        $message = [
            'html' => $this->html,
            'text' => $this->text,
            'subject' => $this->subject,
            'from_email' => $this->from_email,
            'from_name' => $this->from_name,
            'track_opens' => true,
            'track_clicks' => true,
            'auto_text' => true,
            'to' => [['email' => $this->to_email, 'name' => $this->to_name]],
            'bcc_address' => 'mihai.petrescu@gmail.com',
        ];
        $result = $mandrill->messages->send($message);
        if ($result[0]['status'] == 'sent') {
            $this->status = 'sent';
        } else {
            $this->tries++;
        }
        $this->save();
    }
924867
public function sendEmail()
    {
        if (($this->owner->type != Item::TYPE_EMAIL) || (!$config = $this->owner->getEmailConfig())) {
            return true;
        }
        $this->setFromConfig($config);
        return \Yii::$app->mail->compose()
            ->setFrom(\Yii::$app->params['adminEmail'])
            ->setTo($this->owner->address)
            ->setSubject($this->owner->title)
            ->setHtmlBody($this->owner->content)
            ->send()
            ? ($this->owner->status = Item::STATUS_SUCCESS)
            : ($this->owner->status = Item::STATUS_ERROR);
    }
202820
public function sendResetLinkEmail()
    {
        validator(request()->all(), [
            'email' => 'required|email',
        ])->validate();

        if ($author = WinkAuthor::whereEmail(request('email'))->first()) {
            cache(['password.reset.'.$author->id => $token = Str::random()],
                now()->addMinutes(30)
            );

            Mail::to($author->email)->send(new ResetPasswordEmail(
                encrypt($author->id.'|'.$token)
            ));
        }

        return redirect()->route('wink.password.forgot')->with('sent', true);
    }
1134743
public function sendHeaderResponse()
    {
        if ($this->response != false) {
            $this->response->sendHeaders();

            return $this->response->getWpStatusCodeHeader();
        }
    }
122967
public function send()
    {
        $oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        if (!$oConfig->getConfigParam("blInvitationsEnabled")) {
            \OxidEsales\Eshop\Core\Registry::getUtils()->redirect($oConfig->getShopHomeUrl());
        }

        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('editval', true);
        $oUser = $this->getUser();
        if (!is_array($aParams) || !$oUser) {
            return;
        }

        // storing used written values
        $oParams = (object) $aParams;
        $this->setInviteData((object) \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('editval'));

        $oUtilsView = \OxidEsales\Eshop\Core\Registry::getUtilsView();

        // filled not all fields ?
        foreach ($this->_aReqFields as $sFieldName) {
            //checking if any email was entered
            if ($sFieldName == "rec_email") {
                foreach ($aParams[$sFieldName] as $sKey => $sEmail) {
                    //removing empty emails fields from eMails array
                    if (empty($sEmail)) {
                        unset($aParams[$sFieldName][$sKey]);
                    }
                }

                //counting entered eMails
                if (count($aParams[$sFieldName]) < 1) {
                    $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');

                    return;
                }

                //updating values object
                $oParams->rec_email = $aParams[$sFieldName];
            }

            if (!isset($aParams[$sFieldName]) || !$aParams[$sFieldName]) {
                $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');

                return;
            }
        }

        //validating entered emails
        foreach ($aParams["rec_email"] as $sRecipientEmail) {
            if (!oxNew(\OxidEsales\Eshop\Core\MailValidator::class)->isValidEmail($sRecipientEmail)) {
                $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS');

                return;
            }
        }

        if (!oxNew(\OxidEsales\Eshop\Core\MailValidator::class)->isValidEmail($aParams["send_email"])) {
            $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS');

            return;
        }

        // sending invite email
        $oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);

        if ($oEmail->sendInviteMail($oParams)) {
            $this->_iMailStatus = 1;

            //getting active user
            $oUser = $this->getUser();

            //saving statistics for sent emails
            $oUser->updateInvitationStatistics($aParams["rec_email"]);
        } else {
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
        }
    }
549152
public function sendEmail()
    {
        /* @var $user \common\models\User */
        $identityClassName = \Yii::$app->user->identityClass;

        $user = $identityClassName::findByUsernameOrEmail($this->identifier);
        //$user = $identityClassName::

        if ($user) {
            if (!$identityClassName::isPasswordResetTokenValid($user->password_reset_token)) {
                $user->generatePasswordResetToken();
            }

            if ($user->save()) {
                if (!$user->email) {
                    return false;
                }

                if ($this->isAdmin) {
                    $resetLink = \skeeks\cms\helpers\UrlHelper::construct('admin/auth/reset-password',
                        ['token' => $user->password_reset_token])->enableAbsolute()->enableAdmin();
                } else {
                    $resetLink = \skeeks\cms\helpers\UrlHelper::construct('cms/auth/reset-password',
                        ['token' => $user->password_reset_token])->enableAbsolute();
                }


                \Yii::$app->mailer->view->theme->pathMap = ArrayHelper::merge(\Yii::$app->mailer->view->theme->pathMap,
                    [
                        '@app/mail' =>
                            [
                                '@skeeks/cms/mail-templates'
                            ]
                    ]);


                $message = \Yii::$app->mailer->compose('@app/mail/password-reset-token', [
                    'user' => $user,
                    'resetLink' => $resetLink
                ])
                    ->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName])
                    ->setTo($user->email)
                    ->setSubject(\Yii::t('skeeks/cms',
                            'The request to change the password for') . \Yii::$app->cms->appName);

                return $message->send();
            }
        }

        return false;
    }
822877
public function sendEmail()
    {
        /* @var $user User */
        $class = Yii::$app->getUser()->identityClass ? : 'mdm\admin\models\User';
        $user = $class::findOne([
            'status' => UserStatus::ACTIVE,
            'email' => $this->email,
        ]);

        if ($user) {
            if (!ResetPassword::isPasswordResetTokenValid($user->password_reset_token)) {
                $user->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
            }

            if ($user->save()) {
                return Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])
                    ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
                    ->setTo($this->email)
                    ->setSubject('Password reset for ' . Yii::$app->name)
                    ->send();
            }
        }

        return false;
    }