Sends email.

@param  object $mail A mail message.

@throws NetException
964345
public function send($mail)
    {
        $mail = clone $mail;

        try {
            if (!$this->_connection) {
                $this->connect();
            }

            if (($from = $mail->returnPath()) || ($from = $mail->from())) {
                $this->write("MAIL FROM:<" . $from->email() . ">", 250);
            }

            foreach ($mail->recipients() as $recipient) {
                $this->write("RCPT TO:<" . $recipient->email() . ">", [250, 251]);
            }

            $this->write('DATA', 354);
            $this->write(preg_replace('~^\.~m', '..', $mail->toMessage()));
            $this->write('.', 250);

            if (!$this->_persistent) {
                $this->write('QUIT', 221);
                $this->disconnect();
            }
        } catch (NetException $exception) {
            if ($this->_connection) {
                $this->disconnect();
            }
            throw $exception;
        }
    }
1256381
protected function _sendData($email)
    {
        $this->_smtpSend('DATA', '354');

        $headers = $this->_headersToString($this->_prepareMessageHeaders($email));
        $message = $this->_prepareMessage($email);

        $this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n.");
        $this->_content = ['headers' => $headers, 'message' => $message];
    }
440234
static function send( eZMail $mail )
    {
        $ini = eZINI::instance();

        $transportType = trim( $ini->variable( 'MailSettings', 'Transport' ) );

        $optionArray = array( 'iniFile'      => 'site.ini',
                              'iniSection'   => 'MailSettings',
                              'iniVariable'  => 'TransportAlias',
                              'handlerIndex' => strtolower( $transportType ) );
        $options = new ezpExtensionOptions( $optionArray );
        $transportClass = eZExtension::getHandlerClass( $options );

        if ( !is_object( $transportClass ) )
        {
            eZDebug::writeError( "No class available for mail transport type '$transportType', cannot send mail", __METHOD__ );
        }
        return $transportClass->sendMail( $mail );
    }
784060
public function setFrom($email, $name = '')
    {
        if (empty($email)) {
            throw new MailerException('email is required for setFrom!');
        }

        if (empty($name)) {
            $name = substr($email, 0, strrpos($email, '@'));
        }

        if (is_null($this->from)) {
            $this->from = [$email, $name];
        } else {
            throw new MailerException('Sender has already been set!');
        }

        return $this;
    }
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;
	}
654255
public function send(Message $message, array $emails): int
    {
        $this->connect(); // Establish or revive connection
        $this->command("RSET"); // Reset SMTP buffer

        $this->command(sprintf('MAIL FROM:<%1$s>', $message->sender()->email), null, 250); // Set mail from
        $count = 0;
        foreach ($emails as $email) {
            $this->write(sprintf('RCPT TO:<%1$s>', $email));
            $this->read();
            if ($this->lastResponseCode !== 250) {
                throw SMTPException::invalidRecipient(substr($this->lastResponse, 4));
            }

            $count++;
        }

        $messageMime = $message->compile();
        $messageMimeSize = strlen($messageMime);
        if ($this->options["size"] > 0 && $messageMimeSize > $this->options["size"]) {
            throw SMTPException::exceedsMaximumSize($messageMimeSize, $this->options["size"]);
        }

        $this->command("DATA", null, 354);
        $this->write($messageMime); // Write MIME
        $this->command(".", null, 250); // End DATA

        // Keep alive?
        if (!$this->keepAlive) {
            $this->write("QUIT"); // Send QUIT command
            //unset($this->stream);
            $this->stream = null;  // Close stream resource
        }

        return $count;
    }
1163255
public function mail($from)
    {
        if ($this->_helo == false) {
            throw new SMTPException(__('Must call EHLO (or HELO) before calling MAIL'));
        } elseif ($this->_mail !== false) {
            throw new SMTPException(__('Only one call to MAIL may be made at a time.'));
        }

        $this->_send('MAIL FROM:<' . $from . '>');
        $this->_expect(250, 300);

        $this->_from = $from;
        $this->_mail = true;
        $this->_rcpt = false;
        $this->_data = false;
    }
667582
public function sendEmail(Exception $exception)
    {
        try {
            $e = FlattenException::create($exception);
            $handler = new SymfonyExceptionHandler();
            $html = $handler->getHtml($e);

            Mail::send(new ExceptionOccured($html));
        } catch (Exception $exception) {
            Log::error($exception);
        }
    }
352795
public function send(Email $email)
    {
        $result = $this->execute('emailWithWorker', [
            'email' => $email,
            'transport' => $this->config('transport'),
            'fullBaseUrl' => Configure::read('App.fullBaseUrl'),
        ], $this->config('background'));

        if (!$this->config('background')) {
            return $result;
        }

        return true;
    }
1219197
public function send(Email $email)
    {
        $message = [
            'html' => $email->message(Email::MESSAGE_HTML),
            'text' => $email->message(Email::MESSAGE_TEXT),
            'subject' => mb_decode_mimeheader($email->getSubject()), // Decode because SendGrid is encoding
            'from' => key($email->getFrom()),
            'fromname' => current($email->getFrom()),
            'to' => [],
            'toname' => [],
            'cc' => [],
            'ccname' => [],
            'bcc' => [],
            'bccname' => [],
            'replyto' => $email->getReplyTo() ? array_values($email->getReplyTo())[0] : key($email->getFrom()),
        ];
        // Add recipients
        $recipients = [
            'to' => $email->getTo(),
            'cc' => $email->getCc(),
            'bcc' => $email->getBcc()
        ];
        foreach ($recipients as $type => $emails) {
            foreach ($emails as $mail => $name) {
                $message[$type][] = $mail;
                $message[$type . 'name'][] = $name;
            }
        }

        // Create a new scoped Http Client
        $this->http = new Client([
            'host' => 'api.sendgrid.com',
            'scheme' => 'https',
            'headers' => [
                'User-Agent' => 'CakePHP SendGrid Plugin'
            ]
        ]);

        $message = $this->_attachments($email, $message);

        return $this->_send($message);
    }
761973
public function send(Email $email)
    {
        // Load SparkPost configuration settings
        $apiKey = $this->config('apiKey');

        // Set up HTTP request adapter
        $adapter = new CakeHttpAdapter(new Client());

        // Create SparkPost API accessor
        $sparkpost = new SparkPost($adapter, [ 'key' => $apiKey ]);

        // Pre-process CakePHP email object fields
        $from = (array) $email->from();
        $sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
        $to = (array) $email->to();
        $replyTo = $email->getReplyTo() ? array_values($email->getReplyTo())[0] : null;
        
        foreach ($to as $toEmail => $toName) {
            $recipients[] = ['address' => [ 'name' => mb_encode_mimeheader($toName), 'email' => $toEmail]];
        }

        // Build message to send
        $message = [
            'from' => $sender,
            'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'),
            'text' => $email->message('text'),
            'subject' => mb_decode_mimeheader($email->subject()),
            'recipients' => $recipients
        ];
        
        if ($replyTo) {
	    $message['replyTo'] = $replyTo;
	}

        // Send message
        try {
            $sparkpost->transmission->send($message);
        } catch(APIResponseException $e) {
            // TODO: Determine if BRE is the best exception type
            throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)',
                $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
        }
    }
974235
protected function send($message)
	{
		$message = $this->encodeMessage($message);
		$this->ws->send($message);
	}
429282
private function SendTo($email)
    {
        $texts = array();
        $subject = Trans('Core.Forms.Form.DefaultSubject');
        $mailer = new PHPMailer();
        $mailer->isHTML(false);
        $mailer->CharSet = 'UTF-8';
        $mailer->setFrom($this->form->GetSendFrom());
        foreach($this->Elements()->GetElements() as $element)
        {
            if ($element instanceof Fields\Submit)
            {
                continue;
            }
            $name = $element->GetName();
            if ($name == 'Subject')
            {
                $subject = $this->Value($name);
            }
            else if ($name == 'ReplyTo')
            {
                $mailer->addReplyTo($this->Value($name));
            }
            $texts[] = $name . ": " . $this->Value($name);
        }
        $message = join("\r\n", $texts);
        $mailer->Subject = $subject;
        $mailer->Body = $message;
        $mailer->addAddress($email);
        $mailer->send();
    }
897385
protected function _sendMail()
    {
        $result = false;
        try {
            $result = parent::send();
        } catch (Exception $exception) {
            $ex = oxNew(\OxidEsales\Eshop\Core\Exception\StandardException::class);
            $ex->setMessage($exception->getMessage());
            if ($this->isDebugModeEnabled()) {
                throw $ex;
            } else {
                \OxidEsales\Eshop\Core\Registry::getLogger()->error($ex->getMessage(), [$ex]);
            }
        }

        return $result;
    }
82936
public static function send(IMailMessage $mail) {
        $success = TRUE;
        try {
            mail($mail->getTo(), $mail->getSubject(), $mail->getBody(), $mail->getHeaders());
        } catch (Exception $exc) {
            $success = FALSE;
        }
        return $success;
    }
1043522
public function sendFromEmail(string $email, \Google_Service_Gmail_Message $message): \Google_Service_Gmail_Message
    {
        return $this->googleServices->getGoogleServiceGmailForEmail($email)->users_messages->send($email, $message);
    }
83991
public function saveMessage($mail)
    {
        try {

            return $this->_storage->saveMessage($mail);

        } catch (\Exception $e) {

            throw new MailException(
                new Phrase($e->getMessage()),
                $e)
            ;

        }
    }