PlainAuthenticator.php 908 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Mailer\Transport\Smtp\Auth;
  11. use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
  12. /**
  13. * Handles PLAIN authentication.
  14. *
  15. * @author Chris Corbyn
  16. */
  17. class PlainAuthenticator implements AuthenticatorInterface
  18. {
  19. public function getAuthKeyword(): string
  20. {
  21. return 'PLAIN';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. *
  26. * @see https://www.ietf.org/rfc/rfc4954.txt
  27. */
  28. public function authenticate(EsmtpTransport $client): void
  29. {
  30. $client->executeCommand(sprintf("AUTH PLAIN %s\r\n", base64_encode($client->getUsername().\chr(0).$client->getUsername().\chr(0).$client->getPassword())), [235]);
  31. }
  32. }