EmailForQueuing.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Mail;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Mail\Mailable;
  6. use Illuminate\Mail\Mailables\Content;
  7. use Illuminate\Mail\Mailables\Envelope;
  8. use Illuminate\Queue\SerializesModels;
  9. use Illuminate\Mail\Mailables\Address;
  10. class EmailForQueuing extends Mailable implements ShouldQueue
  11. {
  12. use Queueable, SerializesModels;
  13. private string $title;
  14. private string $content;
  15. /**
  16. * Create a new message instance.
  17. *
  18. * @return void
  19. */
  20. public function __construct(Address $from, Address $to, string $title, string $content)
  21. {
  22. $this->from($from->address, $from->name);
  23. $this->to($to->address, $to->name);
  24. $this->title = $title;
  25. $this->content = $content;
  26. }
  27. /**
  28. * Get the message envelope.
  29. *
  30. * @return \Illuminate\Mail\Mailables\Envelope
  31. */
  32. public function envelope()
  33. {
  34. return new Envelope(
  35. subject: $this->title
  36. );
  37. }
  38. /**
  39. * Get the message content definition.
  40. *
  41. * @return \Illuminate\Mail\Mailables\Content
  42. */
  43. public function content()
  44. {
  45. return new Content(
  46. view: 'component.form.email',
  47. htmlString: $this->content,
  48. );
  49. }
  50. /**
  51. * Get the attachments for the message.
  52. *
  53. * @return array
  54. */
  55. public function attachments()
  56. {
  57. return [];
  58. }
  59. }