vendor/symfony/swiftmailer-bundle/DependencyInjection/SwiftmailerTransportFactory.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;

use Symfony\Component\Routing\RequestContext;

/**
 * Factory to create a \Swift_Transport object.
 *
 * @author Romain Gautier <mail@romain.sh>
 */
class SwiftmailerTransportFactory
{
    /**
     * @param array                         $options
     * @param RequestContext|null           $requestContext
     * @param \Swift_Events_EventDispatcher $eventDispatcher
     *
     * @return \Swift_Transport
     *
     * @throws \InvalidArgumentException if the scheme is not a built-in Swiftmailer transport
     */
    public static function createTransport(array $options, RequestContext $requestContext = null, \Swift_Events_EventDispatcher $eventDispatcher)
    {
        $options = static::resolveOptions($options);

        if ('smtp' === $options['transport']) {
            $smtpAuthHandler = new \Swift_Transport_Esmtp_AuthHandler(array(
                new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(),
                new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(),
                new \Swift_Transport_Esmtp_Auth_PlainAuthenticator(),
            ));
            $smtpAuthHandler->setUsername($options['username']);
            $smtpAuthHandler->setPassword($options['password']);
            $smtpAuthHandler->setAuthMode($options['auth_mode']);

            $transport = new \Swift_Transport_EsmtpTransport(
                new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory()),
                array($smtpAuthHandler),
                $eventDispatcher
            );
            $transport->setHost($options['host']);
            $transport->setPort($options['port']);
            $transport->setEncryption($options['encryption']);
            $transport->setTimeout($options['timeout']);
            $transport->setSourceIp($options['source_ip']);

            $smtpTransportConfigurator = new SmtpTransportConfigurator(null, $requestContext);
            $smtpTransportConfigurator->configure($transport);
        } elseif ('sendmail' === $options['transport']) {
            $transport = new \Swift_Transport_SendmailTransport(

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。