PlainAuthenticator.php 881 B

1234567891011121314151617181920212223242526272829303132333435
  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. * @see https://www.ietf.org/rfc/rfc4954.txt
  25. */
  26. public function authenticate(EsmtpTransport $client): void
  27. {
  28. $client->executeCommand(\sprintf("AUTH PLAIN %s\r\n", base64_encode($client->getUsername().\chr(0).$client->getUsername().\chr(0).$client->getPassword())), [235]);
  29. }
  30. }