function EsmtpTransport::__construct
Overrides SmtpTransport::__construct
File
-
vendor/
symfony/ mailer/ Transport/ Smtp/ EsmtpTransport.php, line 37
Class
- EsmtpTransport
- Sends Emails over SMTP with ESMTP support.
Namespace
Symfony\Component\Mailer\Transport\SmtpCode
public function __construct(string $host = 'localhost', int $port = 0, ?bool $tls = null, ?EventDispatcherInterface $dispatcher = null, ?LoggerInterface $logger = null, ?AbstractStream $stream = null, ?array $authenticators = null) {
parent::__construct($stream, $dispatcher, $logger);
if (null === $authenticators) {
// fallback to default authenticators
// order is important here (roughly most secure and popular first)
$authenticators = [
new Auth\CramMd5Authenticator(),
new Auth\LoginAuthenticator(),
new Auth\PlainAuthenticator(),
new Auth\XOAuth2Authenticator(),
];
}
$this->setAuthenticators($authenticators);
/** @var SocketStream $stream */
$stream = $this->getStream();
if (null === $tls) {
if (465 === $port) {
$tls = true;
}
else {
$tls = \defined('OPENSSL_VERSION_NUMBER') && 0 === $port && 'localhost' !== $host;
}
}
if (!$tls) {
$stream->disableTls();
}
if (0 === $port) {
$port = $tls ? 465 : 25;
}
$stream->setHost($host);
$stream->setPort($port);
}