Message.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Grav\Plugin\Email;
  3. use Symfony\Component\Mime\Email as SymfonyEmail;
  4. class Message
  5. {
  6. /** @var SymfonyEmail */
  7. protected $email;
  8. public function __construct() {
  9. $this->email = new SymfonyEmail();
  10. }
  11. public function subject($subject): self
  12. {
  13. $this->email->subject($subject);
  14. return $this;
  15. }
  16. public function to($to): self
  17. {
  18. $this->email->to($to);
  19. return $this;
  20. }
  21. public function from($from): self
  22. {
  23. $this->email->from($from);
  24. return $this;
  25. }
  26. public function cc($cc): self
  27. {
  28. $this->email->cc($cc);
  29. return $this;
  30. }
  31. public function bcc($bcc): self
  32. {
  33. $this->email->bcc($bcc);
  34. return $this;
  35. }
  36. public function replyTo($reply_to): self
  37. {
  38. $this->email->replyTo($reply_to);
  39. return $this;
  40. }
  41. public function text($text): self
  42. {
  43. $this->email->text($text);
  44. return $this;
  45. }
  46. public function html($html): self
  47. {
  48. $this->email->html($html);
  49. return $this;
  50. }
  51. public function attachFromPath($path): self
  52. {
  53. $this->email->attachFromPath($path);
  54. return $this;
  55. }
  56. public function embedFromPath($path): self
  57. {
  58. $this->email->embedFromPath($path);
  59. return $this;
  60. }
  61. public function reply_to($reply_to): self
  62. {
  63. $this->replyTo($reply_to);
  64. return $this;
  65. }
  66. public function setFrom($from): self
  67. {
  68. $this->from($from);
  69. return $this;
  70. }
  71. public function setTo($to): self
  72. {
  73. $this->to($to);
  74. return $this;
  75. }
  76. public function getEmail(): SymfonyEmail
  77. {
  78. return $this->email;
  79. }
  80. }