Send the given letter. Delivery options should be set optionally for physical letters

@return self
@throws BadResponseException See API Send Reference
333231
public function send(): Letter
    {
        $options = [
            'headers' => [
                'Content-Source' => $this->getEndpointMailbox().'/letters/'.$this->getLetterId(),
            ],
        ];

        if ($this->getEnvelope()->isHybridLetter() && null !== $this->getDeliveryOptions()) {
            $options['headers']['Content-Type'] = $this->getDeliveryOptions()->getMimeType();
            $options['json']                    = $this->getDeliveryOptions();
        }

        $this->getHttpClientForSend()->request('POST', '/deliveries', $options);

        return $this;
    }
599670
public function sendHeaders()
     {
         $response = $this->getResponse();
         $headers = $response->getHeaders();
         $isAjax = $response->getRequest()->isAjax();

         if (isset($headers['Location']) && $response->isSuccess() && !$isAjax) {
             $response->setStatus(AnHttpResponse::SEE_OTHER);
         }

         return parent::sendHeaders();
     }
50257
public function send()
	{
		// load the mail configuration
		$config = \CCConfig::create( 'mail' );
		
		// when mailing is disabled do nothing just return
		if ( $config->disabled === true )
		{
			return;
		}
		
		// we cannot send a mail without recipients
		if ( empty( $this->to ) )
		{
			throw new Exception( "Cannot send mail without recipients." );
		}
		
		// is a catch all enabled?
		if ( $config->get( 'catch_all.enabled' ) === true )
		{
			// to be able to modify the mail without removing
			// the user options we have to clone the mail
			$mail = clone $this;
			
			// we have to remove all recipients ( to, ccc, bcc ) and set them
			// to our catch all recipients
			$mail->to = array();
			$mail->cc = array();
			$mail->bcc = array();
			
			$mail->to( $config->get( 'catch_all.addresses' ) );
			
			// transport the cloned mail
			return $mail->transport( $config->get( 'catch_all.transporter' ) );
		}
		
		// transport the mail
		$this->transport();
	}
1282764
public function send()
    {
        $this->_mailer->addAddress($this->to[0], $this->to[1]);
        $this->_mailer->setFrom($this->from[0], $this->from[1]);
        $this->_mailer->isHtml($this->html);
        $this->_mailer->Subject = $this->subject;
        $this->_mailer->Body = $this->body;
        $this->_mailer->AltBody = strip_tags($this->body);

        return $this->_mailer->send();
    }
749251
public function send() {
        $content = '';

        foreach ($this->_message as $message) {
            $content .= $message;
        }

        foreach ($this->_receiver as $receiver) {
            $this->_backline = $this->_setBackLine($receiver);

            //Create the header
            $header = "From: \"" . $this->_sender[0] . "\" <" . $this->_sender[1] . ">" . $this->_backline;
            $header .= "Reply-to: \"" . $this->_reply[0] . "\" <" . $this->_reply[1] . ">" . $this->_backline;
            $header .= "MIME-Version: 1.0" . $this->_backline;

            foreach ($this->_cc as $cc) {
                $header .= "Cc: " . $cc . "" . $this->_backline;
            }

            foreach ($this->_bcc as $bcc) {
                $header .= "Bcc: " . $bcc . "" . $this->_backline;
            }

            foreach ($this->_reception as $reception) {
                $header .= "DispositionNotificationTo: " . $reception . "" . $this->_backline;
            }

            $header .= "Content-Type: " . $this->_fileTransfert . ";" . $this->_backline . " boundary=\"" . $this->_boundary . "\"" . $this->_backline;

            //Create the message
            $message = $this->_backline . "--" . $this->_boundary . $this->_backline;
            $message .= "Content-Type: multipart/alternative;" . $this->_backline . " boundary=\"" . $this->_boundaryAlt . "\"" . $this->_backline;
            $message .= $this->_backline . "--" . $this->_boundaryAlt . $this->_backline;

            if ($this->_formatHtml == self::FORMAT_HTML) {
                $message .= "Content-Type: text/html; charset=\"" . $this->_charset . "\"" . $this->_backline;
                $message .= "Content-Transfer-Encoding: 8bit" . $this->_backline;
                $message .= $this->_backline . $content . $this->_backline;
            }
            elseif ($this->_formatHtml == self::FORMAT_TEXT) {
                $message .= "Content-Type: text/plain; charset=\"" . $this->_charset . "\"" . $this->_backline;
                $message .= "Content-Transfer-Encoding: 8bit" . $this->_backline;
                $message .= $this->_backline . $content . $this->_backline;
            }

            //We close the boundaries
            $message .= $this->_backline . "--" . $this->_boundaryAlt . "--" . $this->_backline;

            foreach ($this->_attachments as $key => $value) {
                $message .= $this->_backline . "--" . $this->_boundary . $this->_backline;
                $message .= "Content-Type: " . $value[1] . "; name=\"" . $key . "\"" . $this->_backline;
                $message .= "Content-Transfer-Encoding: base64" . $this->_backline;
                $message .= "Content-Disposition: attachment; filename=\"" . $key . "\"" . $this->_backline;
                $message .= $this->_backline . $value[0] . $this->_backline . $this->_backline;
            }

            $message .= $this->_backline . "--" . $this->_boundary . "--" . $this->_backline;

            if (Config::config()['user']['mail']['enabled']) {
                mail($receiver, $this->_subject, $message, $header);
            }
        }
    }
1308720
public function badRequest(): Response
    {
        $this->response->setStatus(400);
        $this->response->setBody('<html><title>400 Bad Request</title>400 Bad Request</html>');
        return $this->response;
    }
265413
protected function sendWebServiceRequest()
    {
        $this->response = $this->http->post(WebService::SIGEP, [
            'http_errors' => false,
            'body' => $this->body,
            'headers' => [
                'Content-Type' => 'application/xml; charset=utf-8',
                'cache-control' => 'no-cache',
            ],
        ]);

        return $this;
    }
1055594
public function setReplyToFromDefault() {
        $replyTo = self::getDefaultReplyTo();
        if($replyTo === null) {
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception(
                'No default Reply-To Address set to use');
        }

        $this->setReplyTo($replyTo['email'], $replyTo['name']);

        return $this;
    }
1064851
public function send()
    {
        $this->open();

        if ($this->response === false) {
            throw new \Exception('Error: '.curl_errno($this->resource).' => '.curl_error($this->resource).'.');
        }
        // If the CURLOPT_RETURNTRANSFER option is set to true, get the response body and parse the headers.
        if (isset($this->options[CURLOPT_RETURNTRANSFER]) && ($this->options[CURLOPT_RETURNTRANSFER] == true)) {
            $headerSize = $this->getInfo(CURLINFO_HEADER_SIZE);
            if ($this->options[CURLOPT_HEADER]) {
                $this->responseHeader = substr($this->response, 0, $headerSize);
                $this->body = substr($this->response, $headerSize);
                $this->parseResponseHeaders();
            } else {
                $this->body = $this->response;
            }
        }

        if (array_key_exists('Content-Encoding', $this->responseHeaders)) {
            $this->decodeBody();
        }
    }
574901
private function sendMail() {

		// check for configured mailer

		if(is_null($this->mailer) && !is_null(Application::getInstance()->getConfig()->mail->mailer)) {

			$mailer = Application::getInstance()->getConfig()->mail->mailer;
			$reflection = new \ReflectionClass(str_replace('/', '\\', $mailer->class));
			
			$port = isset($mailer->port) ? $mailer->port : null;
			$encryption = isset($mailer->encryption) ? $mailer->encryption : null;

			$this->mailer = $reflection->newInstanceArgs([$mailer->host, $port, $encryption]);

			if(isset($mailer->auth_type)) {
				$this->mailer->setCredentials($mailer->user, $mailer->pass, $mailer->auth_type);
			}
			else {
				$this->mailer->setCredentials($mailer->user, $mailer->pass);
			}
		}

		if(is_null($this->mailer)) {

			// use PHP's own mail() function

			$headers = [];

			foreach($this->headers as $k => $v) {
				$headers[] = iconv_mime_encode($k, $v);
			}

			mb_internal_encoding($this->encoding);

			// @todo ensure receiver to be RFC conforming

			return mail(
				implode(',', $this->receiver),
				mb_encode_mimeheader($this->subject, mb_internal_encoding(), 'Q'),
				$this->msg,
				implode(self::CRLF, $headers)
			);
		}

		else {

			// send mail with configured mailer

			try {
				$this->mailer->connect();

				$this->mailer->setFrom($this->sender);
				$this->mailer->setTo(array_merge((array) $this->receiver, $this->cc, $this->bcc));
				$this->mailer->setHeaders(array_merge(
					[
						'To' => implode(',', (array) $this->receiver),
						'Subject' => $this->subject
					],
					$this->headers
				));
				$this->mailer->setMessage($this->msg);
				$this->mailer->send();

				$this->mailer->close();
				return true;
			}

			catch(MailerException $e) {
				$this->mailer->close();
				return $e->getMessage();
			}
		}
	}
377101
public function send()
    {

        if ($this->Logger->isEnabled()) {
            if($this->mailer->IsError())
                $this->Logger->debug("ERROR OCCURRED");

            $this->Logger->debug("Headers:\n".$this->mailer->CreateHeader());
            $this->Logger->debug("Body:\n".$this->mailer->CreateBody());
        }

        if (!$this->testingOnly) {
            try {
                $this->mailer->Send();
            } catch (phpmailerException $e) {
                throw new EmailException($e->getMessage(), $e->getCode());
            }

        }
        return true;
    }
1021465
public function send()
    {
        $this->hash();

        if ($data = $this->handle('beforeExecuteReturn')) {
            return $data;
        }

        if (!empty($this->payload)) {
            $this->serialized_payload = $this->handle('serialize', $this->payload);
        }

        $this->uri = $this->formatEndpoint();

        $this->handle('beforeExecute');

        $exception = false;
        $res       = null;

        try {
            $client = new Client();

            $res = $client->request(
                $this->method,
                $this->uri,
                $this->headers + $this->formatBody() + $this->options
            );

        } catch (Exception $e) {
            $exception = $e;
        }

        if (is_bool($exception) && $res instanceof Response) {
            $body = $this->handle('parse', $res->getBody());

            if ($data = $this->handle('afterExecuteReturn', $body)) {
                return $data;
            }

            $this->handle('afterExecute', $body);

            return $body;
        }

        $msg = null;

        if ($exception instanceof Exception) {
            $msg = $exception->getMessage();

            if ($exception instanceof RequestException) {
                $msg = $exception->getRequest();

                if ($exception->hasResponse()) {
                    $msg = $exception->getResponse()->getBody()->getContents();
                }
            }
        }

        return $this->handle('error', $msg, ['exception' => $exception instanceof Exception ? $exception : null]);
    }
765625
public function send()
    {
        $curl = curl_init();

        $this->addParameters()->addHeaders();
        curl_setopt_array($curl, $this->options);
        curl_exec($curl);

        $this->meta = array(
            'info'             => curl_getinfo($curl, CURLINFO_HTTP_CODE),
            'error_message'    => curl_errno($curl),
            'error_code'    => curl_error($curl));

        curl_close($curl);
        unset($curl);

        return $this;
    }
962708
public function deliver()
    {
        $this->checkAuth();
        $this->checkCartNotEmpty();

        $message = false;

        $orderDelivery = $this->createForm(FrontForm::ORDER_DELIVER);

        try {
            $form = $this->validateForm($orderDelivery, "post");

            $deliveryAddressId = $form->get("delivery-address")->getData();
            $deliveryModuleId = $form->get("delivery-module")->getData();
            $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
            $deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId);

            /* check that the delivery address belongs to the current customer */
            if ($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
                throw new \Exception(
                    $this->getTranslator()->trans(
                        "Delivery address does not belong to the current customer",
                        [],
                        Front::MESSAGE_DOMAIN
                    )
                );
            }

            /* check that the delivery module fetches the delivery address area */
            if (null === AreaDeliveryModuleQuery::create()->findByCountryAndModule(
                $deliveryAddress->getCountry(),
                $deliveryModule
            )) {
                throw new \Exception(
                    $this->getTranslator()->trans(
                        "Delivery module cannot be use with selected delivery address",
                        [],
                        Front::MESSAGE_DOMAIN
                    )
                );
            }

            /* get postage amount */
            $moduleInstance = $deliveryModule->getDeliveryModuleInstance($this->container);

            $cart = $this->getSession()->getSessionCart($this->getDispatcher());
            $deliveryPostageEvent = new DeliveryPostageEvent($moduleInstance, $cart, $deliveryAddress);

            $this->getDispatcher()->dispatch(
                TheliaEvents::MODULE_DELIVERY_GET_POSTAGE,
                $deliveryPostageEvent
            );

            if (!$deliveryPostageEvent->isValidModule() || null === $deliveryPostageEvent->getPostage()) {
                throw new DeliveryException(
                    $this->getTranslator()->trans('The delivery module is not valid.', [], Front::MESSAGE_DOMAIN)
                );
            }

            $postage = $deliveryPostageEvent->getPostage();

            $orderEvent = $this->getOrderEvent();
            $orderEvent->setDeliveryAddress($deliveryAddressId);
            $orderEvent->setDeliveryModule($deliveryModuleId);
            $orderEvent->setPostage($postage->getAmount());
            $orderEvent->setPostageTax($postage->getAmountTax());
            $orderEvent->setPostageTaxRuleTitle($postage->getTaxRuleTitle());

            $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
            $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
            $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);

            return $this->generateRedirectFromRoute("order.invoice");

        } catch (FormValidationException $e) {
            $message = $this->getTranslator()->trans(
                "Please check your input: %s",
                ['%s' => $e->getMessage()],
                Front::MESSAGE_DOMAIN
            );
        } catch (PropelException $e) {
            $this->getParserContext()->setGeneralError($e->getMessage());
        } catch (\Exception $e) {
            $message = $this->getTranslator()->trans(
                "Sorry, an error occured: %s",
                ['%s' => $e->getMessage()],
                Front::MESSAGE_DOMAIN
            );
        }

        if ($message !== false) {
            Tlog::getInstance()->error(
                sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())
            );

            $orderDelivery->setErrorMessage($message);

            $this->getParserContext()
                ->addForm($orderDelivery)
                ->setGeneralError($message)
            ;
        }
    }
30011
public function _sendMail()
    {
        if ($this->parameters === null) {
            set_error_handler(array($this, '_handleMailErrors'));
            $result = mail(
                $this->recipients,
                $this->_mail->getSubject(),
                $this->body,
                $this->header);
            restore_error_handler();
        } else {
            if(!is_string($this->parameters)) {
                /**
                 * @see Zend_Mail_Transport_Exception
                 *
                 * Exception is thrown here because
                 * $parameters is a public property
                 */
                // require_once 'Zend/Mail/Transport/Exception.php';
                throw new Zend_Mail_Transport_Exception(
                    'Parameters were set but are not a string'
                );
            }

            set_error_handler(array($this, '_handleMailErrors'));
            $result = mail(
                $this->recipients,
                $this->_mail->getSubject(),
                $this->body,
                $this->header,
                $this->parameters);
            restore_error_handler();
        }

        if ($this->_errstr !== null || !$result) {
            /**
             * @see Zend_Mail_Transport_Exception
             */
            // require_once 'Zend/Mail/Transport/Exception.php';
            throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr);
        }
    }
435000
public function send()
    {
        foreach ($this->messages as $mail) {
            $this->mailer->send($mail);
        }
        return $this;
    }
54194
public function send()
	{
		if(!$this->verify())
			throw new \MalformesResponseException("Malformed response");
		else
		{
			http_response_code($this->statusCode);
			
			foreach($this->headers as $header => $value)
			{
				header($header . ': ' . $value);
			}
		}
		
		echo $this->body;
	}