php-mailer.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. return array(
  49. 'Host' => array(
  50. array(
  51. 'type' => 'input',
  52. 'name' => 'PHPMAILER-smtpHost',
  53. 'label' => 'SMTP Host',
  54. 'value' => $GLOBALS['PHPMAILER-smtpHost']
  55. ),
  56. array(
  57. 'type' => 'input',
  58. 'name' => 'PHPMAILER-smtpHostPort',
  59. 'label' => 'SMTP Port',
  60. 'value' => $GLOBALS['PHPMAILER-smtpHostPort']
  61. )
  62. ),
  63. 'Authentication' => array(
  64. array(
  65. 'type' => 'input',
  66. 'name' => 'PHPMAILER-smtpHostUsername',
  67. 'label' => 'Username',
  68. 'value' => $GLOBALS['PHPMAILER-smtpHostUsername']
  69. ),
  70. array(
  71. 'type' => 'password',
  72. 'name' => 'PHPMAILER-smtpHostPassword',
  73. 'label' => 'Password',
  74. 'value' => $GLOBALS['PHPMAILER-smtpHostPassword']
  75. ),
  76. array(
  77. 'type' => 'switch',
  78. 'name' => 'PHPMAILER-smtpHostAuth',
  79. 'label' => 'Authentication',
  80. 'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
  81. ),
  82. array(
  83. 'type' => 'select',
  84. 'name' => 'PHPMAILER-smtpHostType',
  85. 'label' => 'Authentication Type',
  86. 'value' => $GLOBALS['PHPMAILER-smtpHostType'],
  87. 'options' => array(
  88. array(
  89. 'name'=>'tls',
  90. 'value'=>'tls'
  91. ),
  92. array(
  93. 'name'=>'ssl',
  94. 'value'=>'ssl'
  95. ),
  96. array(
  97. 'name'=>'off',
  98. 'value'=>'false'
  99. )
  100. )
  101. )
  102. ),
  103. 'Sender Information' => array(
  104. array(
  105. 'type' => 'input',
  106. 'name' => 'PHPMAILER-smtpHostSenderName',
  107. 'label' => 'Sender Name',
  108. 'value' => $GLOBALS['PHPMAILER-smtpHostSenderName']
  109. ),
  110. array(
  111. 'type' => 'input',
  112. 'name' => 'PHPMAILER-smtpHostSenderEmail',
  113. 'label' => 'Sender Email',
  114. 'value' => $GLOBALS['PHPMAILER-smtpHostSenderEmail'],
  115. 'placeholder' => 'i.e. same as username'
  116. )
  117. ),
  118. 'Test' => array(
  119. array(
  120. 'type' => 'button',
  121. 'label' => 'Send Test',
  122. 'class' => 'phpmSendTestEmail',
  123. 'icon' => 'fa fa-paper-plane',
  124. 'text' => 'Send'
  125. )
  126. )
  127. );
  128. }