LoginAuthenticator.php 991 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 LOGIN authentication.
  14. *
  15. * @author Chris Corbyn
  16. */
  17. class LoginAuthenticator implements AuthenticatorInterface
  18. {
  19. public function getAuthKeyword(): string
  20. {
  21. return 'LOGIN';
  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("AUTH LOGIN\r\n", [334]);
  31. $client->executeCommand(sprintf("%s\r\n", base64_encode($client->getUsername())), [334]);
  32. $client->executeCommand(sprintf("%s\r\n", base64_encode($client->getPassword())), [235]);
  33. }
  34. }