php-mailer.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. // PLUGIN INFORMATION
  3. $GLOBALS['plugins'][]['PHP Mailer'] = array( // Plugin Name
  4. 'name'=>'PHP Mailer', // Plugin Name
  5. 'author'=>'PHP Mailer', // Who wrote the plugin
  6. 'category'=>'Mail', // One to Two Word Description
  7. 'link'=>'https://github.com/PHPMailer/PHPMailer', // Link to plugin info
  8. //'fileName'=>'php-mailer.php',
  9. //'configFile'=>'php-mailer.php',
  10. //'apiFile'=>'php-mailer.php',
  11. 'idPrefix'=>'PHPMAILER', // html element id prefix
  12. 'configPrefix'=>'PHPMAILER', // config file prefix for array items without the hypen
  13. 'version'=>'1.0.0', // SemVer of plugin
  14. 'image'=>'plugins/images/php-mailer.png', // 1:1 non transparent image for plugin
  15. 'settings'=>true, // does plugin need a settings page? true or false
  16. 'homepage'=>false // Is plugin for use on homepage? true or false
  17. );
  18. // INCLUDE/REQUIRE FILES
  19. // PLUGIN FUNCTIONS
  20. function phpmSendTestEmail(){
  21. try {
  22. $mail = new PHPMailer\PHPMailer\PHPMailer(true);
  23. $mail->isSMTP();
  24. //$mail->SMTPDebug = 3;
  25. $mail->Host = $GLOBALS['PHPMAILER-smtpHost'];
  26. $mail->Port = $GLOBALS['PHPMAILER-smtpHostPort'];
  27. $mail->SMTPSecure = $GLOBALS['PHPMAILER-smtpHostType'];
  28. $mail->SMTPAuth = $GLOBALS['PHPMAILER-smtpHostAuth'];
  29. $mail->Username = $GLOBALS['PHPMAILER-smtpHostUsername'];
  30. $mail->Password = decrypt($GLOBALS['PHPMAILER-smtpHostPassword']);
  31. $mail->setFrom($GLOBALS['PHPMAILER-smtpHostSenderEmail'], $GLOBALS['PHPMAILER-smtpHostSenderName']);
  32. $mail->addReplyTo($GLOBALS['PHPMAILER-smtpHostSenderEmail'], $GLOBALS['PHPMAILER-smtpHostSenderName']);
  33. $mail->isHTML(true);
  34. $mail->addAddress($GLOBALS['organizrUser']['email'], $GLOBALS['organizrUser']['username']);
  35. $mail->Subject = "Organizr Test E-Mail";
  36. $mail->Body = "This was just a test!";
  37. $mail->send();
  38. writeLog('success', 'Mail Function - E-Mail Test Sent', $GLOBALS['organizrUser']['username']);
  39. return true;
  40. } catch (PHPMailer\PHPMailer\Exception $e) {
  41. writeLog('error', 'Mail Function - E-Mail Test Failed['.$mail->ErrorInfo.']', $GLOBALS['organizrUser']['username']);
  42. return $e->errorMessage();
  43. }
  44. return false;
  45. }
  46. /* GET PHPMAILER SETTINGS */
  47. function phpmGetSettings(){
  48. /*$like = 'PHPMAILER';
  49. return array_filter_key(configLazy(), function ($item) use ($like) {
  50. if (stripos($item, $like) !== false) {
  51. return true;
  52. }
  53. return false;
  54. });*/
  55. /*
  56. 'PHPMAILER-enabled' => false,
  57. 'PHPMAILER-smtpHost' => '',
  58. 'PHPMAILER-smtpHostPort' => '',
  59. 'PHPMAILER-smtpHostAuth' => true,
  60. 'PHPMAILER-smtpHostUsername' => '',
  61. 'PHPMAILER-smtpHostPassword' => '',
  62. 'PHPMAILER-smtpHostSenderName' => 'Organizr',
  63. 'PHPMAILER-smtpHostSenderEmail' => 'no-reply@Organizr.tld',
  64. 'PHPMAILER-smtpHostType' => 'tls'
  65. */
  66. return array(
  67. array(
  68. 'type' => 'input',
  69. 'name' => 'PHPMAILER-smtpHost',
  70. 'label' => 'SMTP Host',
  71. 'value' => $GLOBALS['PHPMAILER-smtpHost']
  72. ),
  73. array(
  74. 'type' => 'input',
  75. 'name' => 'PHPMAILER-smtpHostPort',
  76. 'label' => 'SMTP Port',
  77. 'value' => $GLOBALS['PHPMAILER-smtpHostPort']
  78. ),
  79. array(
  80. 'type' => 'input',
  81. 'name' => 'PHPMAILER-smtpHostUsername',
  82. 'label' => 'Username',
  83. 'value' => $GLOBALS['PHPMAILER-smtpHostUsername']
  84. ),
  85. array(
  86. 'type' => 'password',
  87. 'name' => 'PHPMAILER-smtpHostPassword',
  88. 'label' => 'Password',
  89. 'value' => $GLOBALS['PHPMAILER-smtpHostPassword']
  90. ),
  91. array(
  92. 'type' => 'input',
  93. 'name' => 'PHPMAILER-smtpHostSenderName',
  94. 'label' => 'Sender Name',
  95. 'value' => $GLOBALS['PHPMAILER-smtpHostSenderName']
  96. ),
  97. array(
  98. 'type' => 'input',
  99. 'name' => 'PHPMAILER-smtpHostSenderEmail',
  100. 'label' => 'Sender Email',
  101. 'value' => $GLOBALS['PHPMAILER-smtpHostSenderEmail'],
  102. 'placeholder' => 'i.e. same as username'
  103. ),
  104. array(
  105. 'type' => 'switch',
  106. 'name' => 'PHPMAILER-smtpHostAuth',
  107. 'label' => 'Authentication',
  108. 'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
  109. ),
  110. array(
  111. 'type' => 'select',
  112. 'name' => 'PHPMAILER-smtpHostType',
  113. 'label' => 'Authentication Type',
  114. 'value' => $GLOBALS['PHPMAILER-smtpHostType'],
  115. 'options' => array(
  116. array(
  117. 'name'=>'tls',
  118. 'value'=>'tls'
  119. ),
  120. array(
  121. 'name'=>'ssl',
  122. 'value'=>'ssl'
  123. ),
  124. array(
  125. 'name'=>'off',
  126. 'value'=>'false'
  127. )
  128. )
  129. ),
  130. array(
  131. 'type' => 'button',
  132. 'label' => 'Send Test',
  133. 'class' => 'phpmSendTestEmail',
  134. 'icon' => 'fa fa-paper-plane',
  135. 'text' => 'Send'
  136. )
  137. );
  138. }