创建一个sendmail传输对象

@param $sendmail null|string sendmail配置

@return Swift_SendmailTransport
763274
public function createSendmailDriver($sendmail = null)
    {
        $transport = Swift_SendmailTransport::newInstance(
            $sendmail ? $sendmail : Config::get('sendmail')
        );

        return $transport;
    }
1354640
public function sendMail(Request $request)
    {
        if (null === $mail = $request->request->get('email')) {
            $this->app->abort(400, 'Bad request missing email parameter');
        };

        if (!\Swift_Validate::email($mail)) {
            $this->app->abort(400, 'Bad request missing email parameter');
        };

        try {
            $receiver = new Receiver(null, $mail);
        } catch (InvalidArgumentException $e) {
            return $this->app->redirectPath('admin_dashboard', ['email' => 'not-sent']);
        }

        $mail = MailTest::create($this->app, $receiver);

        $this->deliver($mail);

        /** @var \Swift_SpoolTransport $spoolTransport */
        $spoolTransport = $this->app['swiftmailer.spooltransport'];
        /** @var \Swift_Transport $transport */
        $transport = $this->app['swiftmailer.transport'];
        $spoolTransport->getSpool()->flushQueue($transport);

        return $this->app->redirectPath('admin_dashboard', ['email' => 'sent']);
    }
299092
public function send()
    {
        if (!$this->mailSender) {
            throw new \Parable\Mail\Exception('No mail sender implementation set.');
        }

        // Check the basics
        if (count($this->addresses['to']) === 0) {
            throw new \Parable\Mail\Exception('No to addresses provided.');
        }
        if (empty($this->subject)) {
            throw new \Parable\Mail\Exception('No subject provided.');
        }
        if (empty($this->body)) {
            throw new \Parable\Mail\Exception('No body provided.');
        }

        // Handle the to, cc and bcc addresses
        $to  = $this->getAddressesForType('to');
        $cc  = $this->getAddressesForType('cc');
        $bcc = $this->getAddressesForType('bcc');

        if (!empty($cc)) {
            $this->addHeader("Cc: {$cc}");
        }
        if (!empty($bcc)) {
            $this->addHeader("Bcc: {$bcc}");
        }

        // Handle from
        $from = $this->getAddressesForType('from');
        $this->addHeader("From: {$from}");

        $headers = array_merge($this->requiredHeaders, $this->headers);
        $headers = implode("\r\n", $headers);

        return $this->getMailSender()->send($to, $this->subject, $this->body, $headers);
    }
113450
public function send(Email $email)
    {
        $eol = PHP_EOL;
        if (isset($this->_config['eol'])) {
            $eol = $this->_config['eol'];
        }
        $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
        $to = $headers['To'];
        unset($headers['To']);
        foreach ($headers as $key => $header) {
            $headers[$key] = str_replace(["\r", "\n"], '', $header);
        }
        $headers = $this->_headersToString($headers, $eol);
        $subject = str_replace(["\r", "\n"], '', $email->getSubject());
        $to = str_replace(["\r", "\n"], '', $to);

        $message = implode($eol, $email->message());

        $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
        $this->_mail($to, $subject, $message, $headers, $params);

        $headers .= $eol . 'To: ' . $to;
        $headers .= $eol . 'Subject: ' . $subject;

        return ['headers' => $headers, 'message' => $message];
    }
1329678
public function send(MailMessage $message)
    {
        $msg = \Swift_Message::newInstance();

        $type = $message->getHtml() ? 'text/html' : null;

        $msg->setSubject($message->getSubject())
            ->setTo($message->getTo())
            ->setFrom($message->getFrom())
            ->setCc($message->getCc())
            ->setBcc($message->getBcc())
            ->setReplyTo($message->getReplyTo())
            ->setBody($message->getBody(), $type, 'utf8');

        $files = $message->getFiles();

        foreach ($files as $file) {
            $attach = \Swift_Attachment::newInstance();

            if ($file->getFilename()) {
                $attach->setFilename($file->getFilename());
            }

            if ($file->getContentType()) {
                $attach->setContentType($file->getContentType());
            }

            $attach->setBody($file->getBody());

            $msg->attach($attach);
        }

        return $this->getMailer()->send($msg);
    }
1292525
public function email($sEmail = null)
    {
        if (null === $sEmail) {
            return $this->getEmail();
        }

        return $this->setEmail($sEmail);
    }
942990
protected function _getTransport()
    {
        if ($this->_mailer === 'smtp') {
            $transport = Swift_SmtpTransport::newInstance($this->_site_settings->smtphost, $this->_site_settings->smtpport)
            ->setUsername($this->_site_settings->smtpuser)
            ->setPassword($this->_site_settings->smtppass);
        } elseif ($this->_mailer === 'sendmail') {
            $transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs');
        } else {
            $transport = Swift_MailTransport::newInstance();
        }

        return $transport;
    }
1234539
public function send($view, array $data = [], $callback = null)
    {
        if ($view instanceof MailableContract) {
            return $this->sendMailable($view);
        }

        // First we need to parse the view, which could either be a string or an array
        // containing both an HTML and plain text versions of the view which should
        // be used when sending an e-mail. We will extract both of them out here.
        [$view, $plain, $raw] = $this->parseView($view);

        $data['message'] = $message = $this->createMessage();

        // Once we have retrieved the view content for the e-mail we will set the body
        // of this message using the HTML type, which will provide a simple wrapper
        // to creating view based emails that are able to receive arrays of data.
        call_user_func($callback, $message);

        $this->addContent($message, $view, $plain, $raw, $data);

        // If a global "to" address has been set, we will set that address on the mail
        // message. This is primarily useful during local development in which each
        // message should be delivered into a single mail address for inspection.
        if (isset($this->to['address'])) {
            $this->setGlobalToAndRemoveCcAndBcc($message);
        }

        // Next we will determine if the message should be sent. We give the developer
        // one final chance to stop this message and then we will send it to all of
        // its recipients. We will then fire the sent event for the sent message.
        $swiftMessage = $message->getSwiftMessage();

        if ($this->shouldSendMessage($swiftMessage, $data)) {
            $this->sendSwiftMessage($swiftMessage);

            $this->dispatchSentEvent($message, $data);
        }
    }
1277387
public function send($closure = null) {

		if(gettype($closure) == 'object') {
			call_user_func($closure, $this);
		}

		//Renders the optional viewmodels and assign the mail variables to them
		foreach($this -> viewmodels as $type => $view) {

			if(null !== $view) {

				$viewmodel = new ViewModel($view, false);
				$viewmodel -> assign($this -> variables);

				$this -> message[$type] = $viewmodel -> render();
			}
		}

		$to 	 = $this -> formatTo();
		$headers = $this -> formatHeaders();
		$message = $this -> formatMessage();

		@mail($to, $this -> subject, $message, $headers);

		if(null === error_get_last()) {
			$this -> send = true;			
		}

		return $this;
	}
63806
public function send()
    {
        $result = $this->mailer->send();

        if ( NULL !== $this->dispatcher )
        {
            $event = new SendMailEvent( $this->to, $this->getSubject(), $this->getBody(), $result );

            $this->dispatcher->fire( Events::EVENT_SEND_MESSAGE, $event );
        }

        return $result;
    }
306421
public function send($message)
    {
        if (!$message instanceof MailMessage) {
            throw new \InvalidArgumentException(
                sprintf('Mailer::%s expect instance of Swift_Message.', __FUNCTION__)
            );
        }

        return $this->swift->send($message, $this->failedRecipients);
    }
257026
public function send($from, $fromName, $to, $toName, $subject, $content)
    {
        $transport = Swift_SmtpTransport::newInstance($this->smtp, $this->port)
            ->setUsername($this->username)
            ->setPassword($this->password);
        $mailer = Swift_Mailer::newInstance($transport);
//        $logger = new Swift_Plugins_Loggers_EchoLogger();
//        $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
        $message = Swift_Message::newInstance();
        $message->setEncoder(Swift_Encoding::get8BitEncoding())
            ->setSubject($subject)
            ->setFrom(array($from => $fromName))
            ->setTo(array($to => $toName))
            ->setBody($content, 'text/html');
//        $message->toString();
//        $logger->dump();
        $result = $mailer->send($message);
        return $result;
    }
1305627
protected static function getMailTransport() {
		if(!isset(PhpReports::$config['mail_settings'])) PhpReports::$config['mail_settings'] = array();
		if(!isset(PhpReports::$config['mail_settings']['method'])) PhpReports::$config['mail_settings']['method'] = 'mail';
		
		switch(PhpReports::$config['mail_settings']['method']) {
			case 'mail':
				return Swift_MailTransport::newInstance();
			case 'sendmail':
				return Swift_MailTransport::newInstance(
					isset(PhpReports::$config['mail_settings']['command'])? PhpReports::$config['mail_settings']['command'] : '/usr/sbin/sendmail -bs'
				);
			case 'smtp':
				if(!isset(PhpReports::$config['mail_settings']['server'])) throw new Exception("SMTP server must be configured");
				$transport = Swift_SmtpTransport::newInstance(
					PhpReports::$config['mail_settings']['server'],
					isset(PhpReports::$config['mail_settings']['port'])? PhpReports::$config['mail_settings']['port'] : 25
				);
				
				//if username/password
				if(isset(PhpReports::$config['mail_settings']['username'])) {
					$transport->setUsername(PhpReports::$config['mail_settings']['username']);
					$transport->setPassword(PhpReports::$config['mail_settings']['password']);
				}
				
				//if using encryption
				if(isset(PhpReports::$config['mail_settings']['encryption'])) {
					$transport->setEncryption(PhpReports::$config['mail_settings']['encryption']);
				}
				
				return $transport;
			default:
				throw new Exception("Mail method must be either 'mail', 'sendmail', or 'smtp'");
		}
	}
483134
public function send(\SendGrid\Mail\Mail $email)
    {
        return $this->client->mail()->send()->post($email);
    }
935312
protected function createSendmailTransport(array $parameters) {
        $transport = Swift_SendmailTransport::newInstance();
        $command = array_get($parameters, 'command');

        if ($command !== null) {
            $transport->setCommand($command);
        }

        return $transport;
    }
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 );
    }
32772
protected function registerSendmailTransport($config)
	{
		$this->app['swift.transport'] = $this->app->share(function($app) use ($config)
		{
			return SendmailTransport::newInstance($config['sendmail']);
		});
	}