Faems.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace addons\faems;
  3. use app\common\library\Email;
  4. use think\Addons;
  5. /**
  6. * 邮件发送插件
  7. */
  8. class Faems extends Addons
  9. {
  10. /**
  11. * 插件安装方法
  12. * @return bool
  13. */
  14. public function install()
  15. {
  16. return true;
  17. }
  18. /**
  19. * 插件卸载方法
  20. * @return bool
  21. */
  22. public function uninstall()
  23. {
  24. return true;
  25. }
  26. /**
  27. * 插件启用方法
  28. * @return bool
  29. */
  30. public function enable()
  31. {
  32. return true;
  33. }
  34. /**
  35. * 插件禁用方法
  36. * @return bool
  37. */
  38. public function disable()
  39. {
  40. return true;
  41. }
  42. /**
  43. * 当发送邮件时
  44. * @return mixed
  45. */
  46. public function emsSend(&$params)
  47. {
  48. $email = new Email();
  49. $result = $email->to($params['email'])
  50. ->subject('请查收你的验证码')
  51. ->message('你的验证码是:' . $params['code'])
  52. ->send();
  53. return $result;
  54. }
  55. /**
  56. * 发送通知
  57. * @param $params
  58. * @return bool
  59. */
  60. public function emsNotice($params)
  61. {
  62. $subject = '你收到一封新的邮件!';
  63. $content = $params['msg'];
  64. $email = new Email();
  65. $result = $email->to($params['email'])
  66. ->subject($subject)
  67. ->message($content)
  68. ->send();
  69. return $result;
  70. }
  71. }