helpers_smtp_hooks.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. use \KarmaFW\Lib\Email_lib;
  3. function smtp_hook_email($to, $subject, $message_html, $message_text='', $from=null, $from_name=null, $options=[]) {
  4. // redirige les emails sortants vers l'adresse SMTP_HOOK_EMAIL
  5. if (! defined('SMTP_HOOK_EMAIL')) {
  6. return false;
  7. }
  8. $to = SMTP_HOOK_EMAIL;
  9. $options['no_hook'] = true;
  10. return \KarmaFW\Lib\Email_lib::sendmailSMTP($to, $subject, $message_html, $message_text, $from, $from_name, $options);
  11. }
  12. function smtp_hook_domain($to, $subject, $message_html, $message_text='', $from=null, $from_name=null, $options=[]) {
  13. // redirige les emails sortants vers le domaine SMTP_HOOK_DOMAIN - exemple: paul.martin@gmail.com => paul.martin__gmail.com@mon-domaine-a-moi.com
  14. if (! defined('SMTP_HOOK_DOMAIN')) {
  15. return false;
  16. }
  17. $to = str_replace("@", "__", $to) . "@" . SMTP_HOOK_DOMAIN;
  18. $options['no_hook'] = true;
  19. return \KarmaFW\Lib\Email_lib::sendmailSMTP($to, $subject, $message_html, $message_text, $from, $from_name, $options);
  20. }
  21. function smtp_hook_false($to, $subject, $message_html, $message_text='', $from=null, $from_name=null, $options=[]) {
  22. // n'envoie aucun email et retourne FALSE
  23. return false;
  24. }
  25. function smtp_hook_true($to, $subject, $message_html, $message_text='', $from=null, $from_name=null, $options=[]) {
  26. // n'envoie aucun email et retourne TRUE
  27. return false;
  28. }