send

@example Send email using SMTP

Mail::send(array(
'to' => "to@email.com",
'from' => "from@email.com",
'body' => "Email body",
'subject' => "Your email subject"
));

@param array $options
491420
public static function send($message)
    {
        if (is_array($message)) {
            $message = new Message($message);
        }

        return static::getMailer()->send($message->getOriginal());
    }
36957
public function execute($options = array())
    {
        $message = $options['message'];
        $receivers = isset($options['attributes']) ? $options['attributes'] : array();
        foreach ($receivers as $receiver) {
            $this->sendNotification($receiver, $message->getBody());
        }
    }
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');
        }
    }
1059781
public function sendEmail($email)
    {
        $user = $this->users->where('email', $email)->first();

        if (! is_null($user)) {
            $user->generatePasswordResetToken();
        }
    }
722474
public function sendEmail($subject, $view, $vars = [])
    {
        $vars['email'] = $email = $this->email;
        $vars['username'] = $username = $this->username;

        Mail::queue(['text' => $view], $vars, function ($message) use ($email, $username, $subject) {
            $message->subject($subject)->to($email, $username);

            if (config()->has('mail.reply_to')) {
                $message->replyTo(
                    config('mail.reply_to.email'),
                    config('mail.reply_to.name')
                );
            }
        });
    }
818879
public function send($to, $subject, $message, $from = 'default', $headerExtra = [], $html = true) {
        if (!is_null($this->method)) { // if a method is set then use that one
            if (is_string($this->method) && ('swift' == $this->method)) {
                return $this->_swiftMail($to, is_string($from) ? $this->from[$from] : $from, $subject, $message, [], $html);
            } else {
                return call_user_func($this->method, $to, is_string($from) ? $this->from[$from] : $from, $subject, $message, [], $headerExtra, $html);
            }
        } // if not use default
        return $this->_mail($to, is_string($from) ? $this->from[$from] : $from, $subject, $message, [], $headerExtra, $html);
    }
1168237
public function send(array $vars = array())
    {
        if (count($this->getTo()) == 0) {
            throw new \InvalidArgumentException('A "To" email address is requried');
        }
        
        if ($this->getSubject() == '') {
            throw new \InvalidArgumentException('A subject for the email must be set');
        }
        
        if ($this->getMessage() == '') {
            throw new \InvalidArgumentException('There isn\'t a message set');
        }
        
        $valid_emails = array();
        foreach ($this->getTo() as $to) {
            if (filter_var(trim($to), FILTER_VALIDATE_EMAIL)) {
                $valid_emails[] = trim($to);
            }
        }
        
        if (! $valid_emails) {
            return;
        }
        
        $mailer = $this->getMailer();
        $subject = $this->getView()->render($this->getSubject(), $vars);
        $body_message = $this->getView()->render($this->getMessage(), $vars);
        $message = $mailer->getMessage($valid_emails, $this->config['from_email'], $this->config['sender_name'], $subject, $body_message, $this->getAttachments(), $this->getMailtype());
        
        if (! $mailer->send($message)) {
            throw new EmailException($this->getMailer()->ErrorInfo);
        }
        
        $this->clear();
    }
911901
protected function _send(array $options) {
        $options['apikey'] = $this->_apiKey;
        $get = array(
            'method' => $options['method'],
            'output' => $this->_outputType
        );
        unset($options['method']);
        
        $uri  = 'http://'.$this->_datacenterId.'.api.mailchimp.com/1.3/?';
        $uri .= http_build_query($get);

        $response = $this->getHttpClient()
                         ->setParameterPost($options)
                         ->setMethod(Zend_Http_Client::POST)
                         ->setUri($uri)
                         ->request()
        ;
        $response = Zend_Json::decode($response->getBody());
        return $response;
    }
312213
public static function email($name, $value = null, array $options = [])
    {
        self::exclure($options);

        return self::input('email', $name, $value, $options);
    }
648504
public function execute($options = array())
    {
        $message = $options['message'];
        $receivers = $message->getReceivers();

        $options['provide_link'] = true;
        foreach ($receivers as $receiver) {
            if ($email = $this->extractEmailFromReceiver($receiver))
                $this->sendMail($message, $email, $options);
        }
    }
424200
def send_form_email(params, subject)
        body = []
        params.each_pair { |k,v| body << "#{k}: #{v}"  }
        BasicMailer.mail(:subject => subject, :body => body.join("\n")).deliver
      end
955170
public function sendEmail($email)
    {
        return Yii::$app->mailer->compose()
            ->setTo($email)
            ->setFrom([$this->email => $this->name])
            ->setSubject($this->subject)
            ->setTextBody($this->body)
            ->send();
    }
1342406
public function send($method, $uri, array $options = [])
    {
        $this->calls[] = array('send', $method, $uri, $options);

        return new Response();
    }
799600
public function send($toEmail, $toName, $subject, $view, array $data = array(), $options = null)
    {
        $this->mail->queue($view, $data, function ($message) use ($toEmail, $toName, $subject, $options) {

            $message->to($toEmail, $toName)
                    ->subject($subject);

            // Allow the caller to run additional functions
            // on the $msg SwiftMailer object (cc, bcc, attach, ...)
            if ($options && is_callable($options)) {
                call_user_func($options, $message);
            }
        });
    }
1373601
public function send(Message $mail) {
		$mails = array();
		if($this->sessionSection->offsetExists('sentMessages')) {
			$mails = $this->sessionSection->sentMessages;
		}

		if (count($mails) === $this->limit) {
			array_pop($mails);
		}

		// get message with generated html instead of set FileTemplate etc
		$reflectionMethod = $mail->getReflection()->getMethod('build');
		$reflectionMethod->setAccessible(TRUE);
		$builtMail = $reflectionMethod->invoke($mail);

		array_unshift($mails, $builtMail);

		$this->sessionSection->sentMessages = $mails;
	}
996243
public function send($to, $subject, $message, $options)
    {
        if (!is_array($options)) {
            $options = array('from' => (string) $options);
        }

        settype($to, 'array');

        $result = null;
        $this->hook->attach('mail.send', $to, $subject, $message, $options, $result);

        if (isset($result)) {
            return $result;
        }

        return $this->mail($to, $subject, $message, $options);
    }
287374
protected function sendRequest($url, $method = 'get', array $options = [])
    {
        return $this->send(
          new Request($method, $url),
          $this->client,
          $options
        );
    }