php-mailer.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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->Host = $GLOBALS['PHPMAILER-smtpHost'];
  25. $mail->SMTPAuth = $GLOBALS['PHPMAILER-smtpHostAuth'];
  26. $mail->Username = $GLOBALS['PHPMAILER-smtpHostUsername'];
  27. $mail->Password = decrypt($GLOBALS['PHPMAILER-smtpHostPassword']);
  28. $mail->SMTPSecure = $GLOBALS['PHPMAILER-smtpHostType'];
  29. $mail->Port = $GLOBALS['PHPMAILER-smtpHostPort'];
  30. $mail->setFrom($GLOBALS['PHPMAILER-smtpHostSenderEmail'], $GLOBALS['PHPMAILER-smtpHostSenderName']);
  31. $mail->addReplyTo($GLOBALS['PHPMAILER-smtpHostSenderEmail'], $GLOBALS['PHPMAILER-smtpHostSenderName']);
  32. $mail->isHTML(true);
  33. $mail->addAddress($GLOBALS['organizrUser']['email'], $GLOBALS['organizrUser']['username']);
  34. $mail->Subject = "Organizr Test E-Mail";
  35. $mail->Body = "This was just a test!";
  36. $mail->send();
  37. writeLog('success', 'Mail Function - E-Mail Test Sent', $GLOBALS['organizrUser']['username']);
  38. return true;
  39. } catch (PHPMailer\PHPMailer\Exception $e) {
  40. writeLog('error', 'Mail Function - E-Mail Test Failed['.$mail->ErrorInfo.']', $GLOBALS['organizrUser']['username']);
  41. return $e->errorMessage();
  42. }
  43. return false;
  44. }
  45. /* GET PHPMAILER SETTINGS */
  46. function phpmGetSettings(){
  47. /*$like = 'PHPMAILER';
  48. return array_filter_key(configLazy(), function ($item) use ($like) {
  49. if (stripos($item, $like) !== false) {
  50. return true;
  51. }
  52. return false;
  53. });*/
  54. /*
  55. 'PHPMAILER-enabled' => false,
  56. 'PHPMAILER-smtpHost' => '',
  57. 'PHPMAILER-smtpHostPort' => '',
  58. 'PHPMAILER-smtpHostAuth' => true,
  59. 'PHPMAILER-smtpHostUsername' => '',
  60. 'PHPMAILER-smtpHostPassword' => '',
  61. 'PHPMAILER-smtpHostSenderName' => 'Organizr',
  62. 'PHPMAILER-smtpHostSenderEmail' => 'no-reply@Organizr.tld',
  63. 'PHPMAILER-smtpHostType' => 'tls'
  64. */
  65. return array(
  66. array(
  67. 'type' => 'input',
  68. 'name' => 'PHPMAILER-smtpHost',
  69. 'label' => 'SMTP Host',
  70. 'value' => $GLOBALS['PHPMAILER-smtpHost']
  71. ),
  72. array(
  73. 'type' => 'input',
  74. 'name' => 'PHPMAILER-smtpHostPort',
  75. 'label' => 'SMTP Port',
  76. 'value' => $GLOBALS['PHPMAILER-smtpHostPort']
  77. ),
  78. array(
  79. 'type' => 'input',
  80. 'name' => 'PHPMAILER-smtpHostUsername',
  81. 'label' => 'Username',
  82. 'value' => $GLOBALS['PHPMAILER-smtpHostUsername']
  83. ),
  84. array(
  85. 'type' => 'password',
  86. 'name' => 'PHPMAILER-smtpHostPassword',
  87. 'label' => 'Password',
  88. 'value' => $GLOBALS['PHPMAILER-smtpHostPassword']
  89. ),
  90. array(
  91. 'type' => 'input',
  92. 'name' => 'PHPMAILER-smtpHostSenderName',
  93. 'label' => 'Sender Name',
  94. 'value' => $GLOBALS['PHPMAILER-smtpHostSenderName']
  95. ),
  96. array(
  97. 'type' => 'input',
  98. 'name' => 'PHPMAILER-smtpHostSenderEmail',
  99. 'label' => 'Sender Email',
  100. 'value' => $GLOBALS['PHPMAILER-smtpHostSenderEmail'],
  101. 'placeholder' => 'i.e. same as username'
  102. ),
  103. array(
  104. 'type' => 'select',
  105. 'name' => 'PHPMAILER-smtpHostType',
  106. 'label' => 'Authentication Type',
  107. 'value' => $GLOBALS['PHPMAILER-smtpHostType'],
  108. 'options' => array(
  109. array(
  110. 'name'=>'tls',
  111. 'value'=>'tls'
  112. ),
  113. array(
  114. 'name'=>'ssl',
  115. 'value'=>'ssl'
  116. ),
  117. array(
  118. 'name'=>'off',
  119. 'value'=>'false'
  120. )
  121. )
  122. ),
  123. array(
  124. 'type' => 'switch',
  125. 'name' => 'PHPMAILER-smtpHostAuth',
  126. 'label' => 'Authentication',
  127. 'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
  128. ),
  129. array(
  130. 'type' => 'button',
  131. 'label' => 'Send Test',
  132. 'class' => 'phpmSendTestEmail',
  133. 'icon' => 'fa fa-paper-plane',
  134. 'text' => 'Send'
  135. )
  136. );
  137. }