Sends email message to user.

@return bool True on success, false otherwise
@throws \BadMethodCallException When "name" or "email" properties are missing
for the provided User entity
164918
public function send()
    {
        if (!$this->_user->has('email') || !$this->_user->has('name')) {
            throw new BadMethodCallException(__d('user', 'Missing "name" or "email" property when trying to send the email.'));
        }

        if ($this->config('updateToken') === true) {
            $this->loadModel('User.Users');
            $this->_user->updateToken();
        }

        $subject = $this->_parseVariables((string)$this->subject());
        $body = $this->_parseVariables((string)$this->body());

        if (empty($subject) || empty($body)) {
            return false;
        }

        $sender = new Email($this->config('emailConfig'));
        $sent = false;
        try {
            $sent = $sender
                ->to($this->_user->get('email'), $this->_user->get('name'))
                ->subject($subject)
                ->send($body);
        } catch (\Exception $e) {
            return false;
        }

        return $sent;
    }
65011
public function sendMessageToEmail(Message $message, $user) {
        if (is_object($user)) {
            $toEmail = $user->getEmail();
        } else {
            $toEmail = $user;
        }

        if ($this->container->hasParameter('mailer_email')) {
            $mailer_email = $this->container->getParameter('mailer_email');
        } else if ($this->container->hasParameter('mailer_user')) {
            $mailer_email = $this->container->getParameter('mailer_user');
        } else {
            $mailer_email = "define@youremail.com";
        }
        $emailMessage = \Swift_Message::newInstance()
            ->setSubject($message->getMySenderEmailSubject($this->container, $user))
            ->setFrom($mailer_email)
            ->setTo($toEmail)
            ->setBody(
                $message->getMySenderEmailBody($this->container, $user),
                'text/html'
            )
        ;

        $senderAttach = $message->getMySenderEmailAttach($this->container, $user);
        if ($senderAttach != null) {
            if (is_array($senderAttach)) {
                foreach($senderAttach as $attach) {
                    $emailMessage->attach(\Swift_Attachment::fromPath($attach));
                }
            } else {
                $emailMessage->attach(\Swift_Attachment::fromPath($senderAttach));
            }
        }

        $this->container->get('mailer')->send($emailMessage);

        return true;
    }
461812
public function send(): void
	{
		/**
		 * Template variables..
		 */
		$this->template->mailData = $this->mailData;

		/**
		 * Stick to convention that Email:
		 * 		/FooMail.php	
		 * 
		 * will have template with path of:
		 * 		/templates/FooMail.latte
		 */
		$mailClassReflection = new \ReflectionClass($this);
		$templateName = $mailClassReflection->getShortName();

		$this->template->setFile(sprintf(
			'%s/templates/%s.latte',
			dirname($mailClassReflection->getFilename()),
			$templateName
		));

		/**
		 * Set body/html body
		 */
		if (version_compare(Engine::VERSION, '2.4.0', '>=')) {
			$this->template->getLatte()->addProvider('uiControl', $this->linkGenerator);
		} else {
			$this->template->_control = $this->linkGenerator;
		}

		$this->message->setHtmlBody((string) $this->template, $this->mailImagesBasePath);

		/**
		 * In case mail sending in on, send message
		 */
		if ($this->config === MailingExtension::CONFIG_BOTH || $this->config === MailingExtension::CONFIG_SEND) {
			$this->mailer->send($this->message);
		}

		/**
		 * In case mail logging is turned on, log message
		 */
		if ($this->config === MailingExtension::CONFIG_LOG || $this->config === MailingExtension::CONFIG_BOTH) {
			$this->logger->log($templateName, $this->message);
		}
	}
647298
public function send()
    {
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('editval', true);
        if (!is_array($aParams)) {
            return;
        }

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

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

        // filled not all fields ?
        foreach ($this->_aReqFields as $sFieldName) {
            if (!isset($aParams[$sFieldName]) || !$aParams[$sFieldName]) {
                $oUtilsView->addErrorToDisplay('SUGGEST_COMLETECORRECTLYFIELDS');

                return;
            }
        }

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

            return;
        }

        $sReturn = "";
        // #1834M - specialchar search
        $sSearchParamForLink = rawurlencode(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('searchparam', true));
        if ($sSearchParamForLink) {
            $sReturn .= "&searchparam=$sSearchParamForLink";
        }

        $sSearchCatId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('searchcnid');
        if ($sSearchCatId) {
            $sReturn .= "&searchcnid=$sSearchCatId";
        }

        $sSearchVendor = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('searchvendor');
        if ($sSearchVendor) {
            $sReturn .= "&searchvendor=$sSearchVendor";
        }

        if (($sSearchManufacturer = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('searchmanufacturer'))) {
            $sReturn .= "&searchmanufacturer=$sSearchManufacturer";
        }

        $sListType = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('listtype');
        if ($sListType) {
            $sReturn .= "&listtype=$sListType";
        }

        // sending suggest email
        $oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);
        $oProduct = $this->getProduct();
        if ($oProduct && $oEmail->sendSuggestMail($oParams, $oProduct)) {
            return 'details?anid=' . $oProduct->getId() . $sReturn;
        } else {
            $oUtilsView->addErrorToDisplay('SUGGEST_INVALIDMAIL');
        }
    }
1277256
public function send()
    {
        $to = $this->getToForSend();
        $headers = $this->getHeadersForSend();

        if (empty($to)) {
            throw new \RuntimeException(
                'Unable to send, no To address has been set.'
            );
        }

        if ($this->hasAttachments()) {
            $message  = $this->assembleAttachmentBody();
            $headers .= PHP_EOL . $this->assembleAttachmentHeaders();
        } else {
            $message = $this->getWrapMessage();
        }

        return mail($to, $this->_subject, $message, $headers, $this->_params);
    }
632911
public function sendOne() {
        $db = \Yii::$app->db;

        $transaction = $db->beginTransaction();
        try {
            $id = $db->createCommand('SELECT id FROM {{%email_message}} WHERE status=:status ORDER BY priority DESC, id ASC LIMIT 1 FOR UPDATE', [
                'status' => Message::STATUS_NEW,
            ])->queryScalar();

            if ($id === false) {
                $transaction->rollback();
                return false;
            }

            /** @var Message $model */
            $model = Message::findOne($id);
            $model->status = Message::STATUS_IN_PROGRESS;
            $model->updateAttributes(['status']);

            $transaction->commit();
        } catch (\Exception $e) {
            $transaction->rollback();
            throw $e;
        }

        $transaction = $db->beginTransaction();
        try {

            $result = EmailManager::getInstance()->send(
                $model->from,
                $model->to,
                $model->subject,
                $model->text,
                $model->files,
                $model->bcc
            );
            if ($result) {
                $model->sentAt = new Expression('NOW()');
                $model->status = Message::STATUS_SENT;
            } else {
                $model->status = Message::STATUS_ERROR;
            }

            $model->updateAttributes(['sentAt', 'status']);
            $transaction->commit();
        } catch (\Exception $e) {
            $transaction->rollback();
            throw $e;
        }

        return true;
    }
1207417
public function sendRecoveryMessage()
    {
        if ($this->validate()) {
            /** @var Token $token */
            $token = new Token([ 'user_id' => $this->user->id, 'type' => Token::TYPE_RECOVERY]);
            $token->save(false);
            $this->module->sendMessage($this->user->email,Yii::t('user', 'Complete password reset on {0}', Yii::$app->name),'recovery',['user' => $this->user, 'token' => $token]);
            Yii::$app->session->setFlash('info', Yii::t('user', 'An email has been sent with instructions for resetting your password'));
            return true;
        }
        return false;
    }
232922
protected function send_mail() {
        // Headers to help prevent auto-responders.
        $userfrom = \core_user::get_noreply_user();
        $userfrom->customheaders = array(
            "Precedence: Bulk",
            'X-Auto-Response-Suppress: All',
            'Auto-Submitted: auto-generated',
        );

        $eventdata = new \core\message\message();
        $eventdata->courseid = SITEID;
        $eventdata->component = 'mod_forum';
        $eventdata->name = 'digests';
        $eventdata->userfrom = $userfrom;
        $eventdata->userto = $this->recipient;
        $eventdata->subject = $this->postsubject;
        $eventdata->fullmessage = $this->notificationtext;
        $eventdata->fullmessageformat = FORMAT_PLAIN;
        $eventdata->fullmessagehtml = $this->notificationhtml;
        $eventdata->notification = 1;
        $eventdata->smallmessage = get_string('smallmessagedigest', 'forum', $this->sentcount);

        return message_send($eventdata);
    }
73471
public function send()
    {
        // if no recipients found, skipping sending
        if (count($this->getRecipient()) < 1) {
            return false;
        }

        $myConfig = Registry::getConfig();
        $this->setCharSet();

        if ($this->_getUseInlineImages()) {
            $this->_includeImages(
                $myConfig->getImageUrl(),
                $myConfig->getImageUrl(false, false),
                $myConfig->getPictureUrl(null, false),
                $myConfig->getImageDir(),
                $myConfig->getPictureDir(false)
            );
        }

        $this->_makeOutputProcessing();

        // try to send mail via SMTP
        if ($this->getMailer() == 'smtp') {
            $ret = $this->_sendMail();

            // if sending failed, try to send via mail()
            if (!$ret) {
                // failed sending via SMTP, sending notification to shop owner
                $this->_sendMailErrorMsg();

                // trying to send using standard mailer
                $this->setMailer('mail');
                $ret = $this->_sendMail();
            }
        } else {
            // sending mail via mail()
            $this->setMailer('mail');
            $ret = $this->_sendMail();
        }

        if (!$ret) {
            // failed sending, giving up, trying to send notification to shop owner
            $this->_sendMailErrorMsg();
        }

        return $ret;
    }
291753
public function preSend()
    {
        try {
            $this->mailHeader = '';
            if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
                throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
            }

            // Set whether the message is multipart/alternative
            if (!empty($this->AltBody)) {
                $this->ContentType = 'multipart/alternative';
            }

            $this->error_count = 0; // reset errors
            $this->setMessageType();
            // Refuse to send an empty message unless we are specifically allowing it
            if (!$this->AllowEmpty and empty($this->Body)) {
                throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
            }

            $this->MIMEHeader = $this->createHeader();
            $this->MIMEBody = $this->createBody();

            // To capture the complete message when using mail(), create
            // an extra header list which createHeader() doesn't fold in
            if ($this->Mailer == 'mail') {
                if (count($this->to) > 0) {
                    $this->mailHeader .= $this->addrAppend('To', $this->to);
                } else {
                    $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
                }
                $this->mailHeader .= $this->headerLine(
                    'Subject',
                    $this->encodeHeader($this->secureHeader(trim($this->Subject)))
                );
            }

            // Sign with DKIM if enabled
            if (!empty($this->DKIM_domain)
                && !empty($this->DKIM_private)
                && !empty($this->DKIM_selector)
                && !empty($this->DKIM_domain)
                && file_exists($this->DKIM_private)) {
                $header_dkim = $this->DKIM_Add(
                    $this->MIMEHeader . $this->mailHeader,
                    $this->encodeHeader($this->secureHeader($this->Subject)),
                    $this->MIMEBody
                );
                $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
                    str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
            }
            return true;

        } catch (phpmailerException $exc) {
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }
            return false;
        }
    }
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');
        });
    }
1237816
public function checkEmailAction()
    {
        $email = $this->container->get('session')->get('fos_user_send_confirmation_email/email');
        $this->container->get('session')->remove('fos_user_send_confirmation_email/email');
        $user = $this->container->get('fos_user.user_manager')->findUserByEmail($email);

        if (null === $user) {
            throw new NotFoundHttpException(
                sprintf('The user with email "%s" does not exist', $email)
            );
        }

        return $this->container->get('templating')->renderResponse(
            'FOSUserBundle:Registration:checkEmail.html.'.$this->getEngine(),
            array(
                'user' => $user,
            )
        );
    }
921671
public function sendRecoveryMessage() {
    if ($this->validate()) {
      /** @var Token $token */
      $token = Yii::createObject([
        'class' => Token::className(),
        'userId' => $this->user->id,
        'type' => Token::TYPE_RECOVERY,
      ]);

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

      if (!$this->mailer->sendRecoveryMessage($this->user, $token)) {
        return false;
      }

      Yii::$app->session->setFlash('info',
        Yii::t('users', 'An email has been sent with instructions for resetting your password')
      );

      return true;
    }

    return false;
  }
275103
public function send()
    {
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        // loads submited values
        $this->_aRegParams = $aParams;

        if (!$aParams['oxuser__oxusername']) {
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');

            return;
        } elseif (!oxNew(\OxidEsales\Eshop\Core\MailValidator::class)->isValidEmail($aParams['oxuser__oxusername'])) {
            // #1052C - eMail validation added
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('MESSAGE_INVALID_EMAIL');

            return;
        }

        $blSubscribe = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("subscribeStatus");

        $oUser = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
        $oUser->oxuser__oxusername = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxusername'], \OxidEsales\Eshop\Core\Field::T_RAW);

        // if such user does not exist
        if (!$oUser->exists()) {
            // and subscribe is off - error, on - create
            if (!$blSubscribe) {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('NEWSLETTER_EMAIL_NOT_EXIST');

                return;
            } else {
                $oUser->oxuser__oxactive = new \OxidEsales\Eshop\Core\Field(1, \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxrights = new \OxidEsales\Eshop\Core\Field('user', \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxshopid = new \OxidEsales\Eshop\Core\Field(\OxidEsales\Eshop\Core\Registry::getConfig()->getShopId(), \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxfname = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxfname'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxlname = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxlname'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxsal = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxsal'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxcountryid = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxcountryid'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $blUserLoaded = $oUser->save();
            }
        } else {
            $blUserLoaded = $oUser->load($oUser->getId());
        }


        // if user was added/loaded successfully and subscribe is on - subscribing to newsletter
        if ($blSubscribe && $blUserLoaded) {
            //removing user from subscribe list before adding
            $oUser->setNewsSubscription(false, false);

            $blOrderOptInEmail = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blOrderOptInEmail');
            if ($oUser->setNewsSubscription(true, $blOrderOptInEmail)) {
                // done, confirmation required?
                if ($blOrderOptInEmail) {
                    $this->_iNewsletterStatus = 1;
                } else {
                    $this->_iNewsletterStatus = 2;
                }
            } else {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('MESSAGE_NOT_ABLE_TO_SEND_EMAIL');
            }
        } elseif (!$blSubscribe && $blUserLoaded) {
            // unsubscribing user
            $oUser->setNewsSubscription(false, false);
            $this->_iNewsletterStatus = 3;
        }
    }
1078941
public function send()
    {
        $useHtml = (bool)$this->getConfig("use_html");

        $mergedHeaders = $this->getMergedHeaders();

        if ($useHtml) {
            $this->setHtmlEmails();
        }

        if ($this->hasConfig("attachedFile")) {
            $status = wp_mail(
                $this->getConfig("to"),
                $this->getConfig("title"),
                $this->getConfig("contents"),
                $this->toHeaderString($mergedHeaders) . $this->buildBCCString(),
                $this->getConfig("attachedFile")
            );
        } else {
            $status = wp_mail(
                $this->getConfig("to"),
                $this->getConfig("title"),
                $this->getConfig("contents"),
                $this->toHeaderString($mergedHeaders) . $this->buildBCCString()
            );
        }

        $logMessage = $status ?
            sprintf("<success>Sent an email</success> to %s with title \"%s\" and a body length of %d characters.", implode(", ", (array)$this->getConfig("to")), $this->getConfig("title"), strlen($this->getConfig("contents"))) :
            sprintf("<warning>Failed to send an email</warning> to %s with title \"%s\" and a body length of %d characters.",  implode(", ", (array)$this->getConfig("to")), $this->getConfig("title"), strlen($this->getConfig("contents")));

        Strata::app()->log($logMessage, "<info>Strata:Mailer</info>");

        if ($useHtml) {
            $this->setHtmlEmails(false);
        }

        return $status;
    }
1282932
public function send()
    {
        $arguments = func_get_args();
        $method    = array_shift($arguments);
        $args      = array_shift($arguments);

        $helpers = $this->getConfig()->getHelpers();

        return call_user_func_array(array($helpers, $method), $args);
    }
939665
public function sendSuccessfulLoginEmailMessage(UserInterface $user)
    {
        /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
        $siteName  = $this->settingsManager->getParameter('general.site_name');
        $userName = sprintf('%s %s', $user->getFirstName(), $user->getLastName());

        $rendered = $this->templating->render(
            'EkynaUserBundle:Security:login_success_email.html.twig',
            [
                'username' => $userName,
                'sitename' => $siteName,
                'date' => new \DateTime()
            ]
        );

        $subject = $this->translator->trans(
            'ekyna_user.email.login_success.subject',
            ['%sitename%' => $siteName]
        );

        $this->sendEmail($rendered, $user->getEmail(), $userName, $subject);
    }