From 820dbed20301c897229e057c7d04c3e740aded4e Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 4 Jul 2011 13:14:45 +0000 Subject: [PATCH] make sure we set SMTPSecure to ssl or tls if the standardports for ssl or tls are configured for the given profile --- phpgwapi/inc/class.egw_mailer.inc.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/phpgwapi/inc/class.egw_mailer.inc.php b/phpgwapi/inc/class.egw_mailer.inc.php index 42ed1358cf..e57d41cd8c 100644 --- a/phpgwapi/inc/class.egw_mailer.inc.php +++ b/phpgwapi/inc/class.egw_mailer.inc.php @@ -88,6 +88,29 @@ class egw_mailer extends PHPMailer private $addresses = array(); + /** + * Initiates a connection to an SMTP server. + * Returns false if the operation failed. + * @uses SMTP + * @access public + * @return bool + */ + public function SmtpConnect() + { + $port = $this->Port; + $hosts = explode(';',$this->Host); + foreach ($hosts as $k => &$host) + { + if (in_array($port,array(465,587)) && strpos($host,'://')===false) + { + //$host = ($port==587?'tls://':'ssl://').trim($host); + $this->SMTPSecure = ($port==587?'tls':'ssl'); + } + //error_log(__METHOD__.__LINE__.' Smtp Host:'.$host.' SmtpSecure:'.($this->SMTPSecure?$this->SMTPSecure:'no')); + } + return parent::SmtpConnect(); + } + /** * Sends mail via SMTP using PhpSMTP *