Mailer.php 924 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. // Copyright 2019 Hackware SpA <human@hackware.cl>
  3. // This file is part of "Hackware Web Services Core" and is released under
  4. // the MIT License terms.
  5. // As far as I can say, this does not violate LGPL.
  6. // Check last paragraph of https://www.gnu.org/licenses/lgpl-java.html
  7. namespace Hawese\Core;
  8. use PHPMailer\PHPMailer\PHPMailer;
  9. /**
  10. * Mailer class
  11. *
  12. * This class shouldn't be directly called, since its instantiation is
  13. * already configured in ./Providers/MailerServiceProvider.php.
  14. *
  15. * Create a ready-to-go instance using `app(\Hawese\Core\Mailer::class)`.
  16. */
  17. class Mailer extends PHPMailer
  18. {
  19. public function send()
  20. {
  21. // Really send only on production, else dump mail into log file
  22. if (app()->environment() == 'production') {
  23. parent::send();
  24. } else {
  25. $this->preSend();
  26. app('log')->info($this->getSentMIMEMessage());
  27. }
  28. }
  29. }