R35613 - /branches/1.8/phpgwapi/inc/class.egw_mailer.inc.php

Author: leithoff
New Revision: 35613

URL: http://svn.stylite.de/viewvc/egroupware?rev=35613&view=rev
Log:
make sure we set SMTPSecure to ssl or tls if the standardports for ssl or tls are configured for the given profile

Modified:
branches/1.8/phpgwapi/inc/class.egw_mailer.inc.php

Modified: branches/1.8/phpgwapi/inc/class.egw_mailer.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/branches/1.8/phpgwapi/inc/class.egw_mailer.inc.php?rev=35613&r1=35612&r2=35613&view=diff

— branches/1.8/phpgwapi/inc/class.egw_mailer.inc.php (original)
+++ branches/1.8/phpgwapi/inc/class.egw_mailer.inc.php Mon Jul 4 15:50:12 2011
@@ -82,4 +82,97 @@
// calling the orginal callback of phpMailer
parent::doCallback($isSent,$to,$cc,$bcc,$subject,$body);
}
+

  • private $addresses = array();
  • /**
    • Initiates a connection to an SMTP server.
    • Returns false if the operation failed.
    • Overwriting this method from phpmailer, to make sure we set SMTPSecure to ssl or tls if the standardports for ssl or tls
    • are configured for the given profile
    • @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
    • Overwriting this method from phpmailer, to allow apps to intercept it
    • via “send_mail” hook, eg. to log or authorize sending of mail.
    • Hooks can throw phpmailerException($message, phpMailer::STOP_CRITICAL),
    • to stop sending the mail out like an SMTP error.
    • @param string $header The message headers
    • @param string $body The message body
    • @return bool
  • */
  • public function SmtpSend($header, $body)
  • {
  •   $GLOBALS['egw']->hooks->process(array(
    
  •   	'location' => 'send_mail',
    
  •   	'subject' => $this->Subject,
    
  •   	'from' => $this->Sender ? $this->Sender : $this->From,
    
  •   	'to' => $this->addresses['To'],
    
  •   	'cc' => $this->addresses['Cc'],
    
  •   	'bcc' => $this->addresses['Bcc'],
    
  •   	'body_sha1' => sha1($body),
    
  •   	'message_id' => preg_match('/^Message-ID: (.*)$/m', $header,$matches) ? $matches[1] : null,
    
  •   ), array(), true);	// true = call all apps
    
  •   $this->addresses = array();	// reset addresses for next mail
    
  •   // calling the overwritten method
    
  •   return parent::SmtpSend($header, $body);
    
  • }
  • /**
    • Creates recipient headers.
    • Overwritten to get To, Cc and Bcc addresses, which are private in phpMailer
    • @access public
    • @return string
  • */
  • public function AddrAppend($type, $addr)
  • {
  •   foreach($addr as $data)
    
  •   {
    
  •   	$this->addresses[$type][] = $data[0];
    
  •   }
    
  •   return parent::AddrAppend($type, $addr);
    
  • }
  • /**
    • Adds a “Bcc” address.
    • Reimplemented as AddrAppend() for Bcc get’s NOT called for SMTP!
    • @param string $address
    • @param string $name
    • @return boolean true on success, false if address already used
  • */
  • public function AddBCC($address, $name = ‘’)
  • {
  •   $this->AddrAppend('Bcc', array(array($address,$name)));
    
  •   return parent::AddBCC($address, $name);
    
  • }
    }

All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2


eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs