[Mapbender-commits] r10207 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 13 03:09:48 PDT 2019


Author: hollsandre
Date: 2019-08-13 03:09:48 -0700 (Tue, 13 Aug 2019)
New Revision: 10207

Modified:
   trunk/mapbender/http/classes/class_administration.php
Log:
added phpmailer for php7

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2019-08-13 05:57:52 UTC (rev 10206)
+++ trunk/mapbender/http/classes/class_administration.php	2019-08-13 10:09:48 UTC (rev 10207)
@@ -21,9 +21,15 @@
 require_once(dirname(__FILE__)."/class_cache.php");
 require_once dirname(__FILE__) . "/../../tools/wms_extent/extent_service.conf";
 # changed to Version 6.0.2 due to dprecated/removed functionality (php7+) TODO - check invokation of new class !!!!
-require(dirname(__FILE__) . "/phpmailer-1.72/class.phpmailer.php");
-#require(dirname(__FILE__) . "/phpmailer-6.0.2/src/PHPMailer.php");
-
+$phpversion = phpversion();
+if (strpos($phpversion, "7.") === 0) {
+    //use new mailer
+    require(dirname(__FILE__) . "/phpmailer-6.0.2/src/PHPMailer.php");
+    require(dirname(__FILE__) . "/phpmailer-6.0.2/src/SMTP.php");
+    require(dirname(__FILE__) . "/phpmailer-6.0.2/src/Exception.php");
+} else {
+    require(dirname(__FILE__) . "/phpmailer-1.72/class.phpmailer.php");
+}
 /**
  * class to wrap administration methods
  *
@@ -30,6 +36,7 @@
  * @uses phpmailer
  */ 
 class administration {
+
     /**
      * checks whether the passed email-address is valid / following a pattern
      * @todo is this an exact representation of the RFC 2822?
@@ -39,6 +46,19 @@
      * @param <string> a all lowercase email adress to test
      * @return <boolean> answer to "is the passed over email valid?""
      */
+	function getPhpVersion() {
+	    return phpversion();
+	}
+
+    /**
+     * checks whether the passed email-address is valid / following a pattern
+     * @todo is this an exact representation of the RFC 2822?
+     * @todo this should be checked: what about umlaut-domains and tld like '.museum'?
+     * @see http://tools.ietf.org/html/rfc2822
+     *
+     * @param <string> a all lowercase email adress to test
+     * @return <boolean> answer to "is the passed over email valid?""
+     */
 	function isValidEmail($email) {
         if(mb_eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
             return true;
@@ -89,19 +109,27 @@
 		}
 
 		if ($this->isValidEmail($fromAddr) && $this->isValidEmail($toAddr)) {
-			$mail = new PHPMailer();
-
+			$phpversion = $this->getPhpVersion();
+			if (strpos($phpversion, "7.") === 0) {
+    			    //use new mailer
+                            $mail = new PHPMailer\PHPMailer\PHPMailer();
+                            $mail->SMTPOptions = array(
+                                'ssl' => array(
+                                    'verify_peer' => false,
+                                    'verify_peer_name' => false,
+                                    'allow_self_signed' => true
+                                 )
+                            );
+                            $mail->Port = 25;
+			} else {
+    			    $mail = new PHPMailer();
+			}
 			if ($fromName != "" ) {
 				$mail->FromName = $fromName;
 			}
-
 			$mail->IsSMTP();                  // set mailer to use SMTP
 			$mail->Host = $mailHost;          // specify main and backup server
-			$mail->SMTPAuth = true;           // turn on SMTP authentication
-			$mail->Username = $mailUsername;  // SMTP username
-			$mail->Password = $mailPassword;  // SMTP password
-
-			$mail->From = $fromAddr;
+			$mail->setFrom($fromAddr,$fromName);
 			$mail->AddAddress($toAddr, $toName);
 			#$mail->AddReplyTo("info at ccgis.de", "Information");
 



More information about the Mapbender_commits mailing list