Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MessagePart.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Mime\Part;
  11. use Symfony\Component\Mime\Message;
  12. use Symfony\Component\Mime\RawMessage;
  13. /**
  14. * @final
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. *
  18. * @experimental in 4.3
  19. */
  20. class MessagePart extends DataPart
  21. {
  22. private $message;
  23. public function __construct(RawMessage $message)
  24. {
  25. if ($message instanceof Message) {
  26. $name = $message->getHeaders()->getHeaderBody('Subject').'.eml';
  27. } else {
  28. $name = 'email.eml';
  29. }
  30. parent::__construct('', $name);
  31. $this->message = $message;
  32. }
  33. public function getMediaType(): string
  34. {
  35. return 'message';
  36. }
  37. public function getMediaSubtype(): string
  38. {
  39. return 'rfc822';
  40. }
  41. public function getBody(): string
  42. {
  43. return $this->message->toString();
  44. }
  45. public function bodyToString(): string
  46. {
  47. return $this->getBody();
  48. }
  49. public function bodyToIterable(): iterable
  50. {
  51. return $this->message->toIterable();
  52. }
  53. }