1<?php 2/** 3 * Copyright 2014-2016 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (LGPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 7 * 8 * @category Horde 9 * @copyright 2014-2016 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Mail_Autoconfig 12 */ 13 14/** 15 * Autoconfigured configuration details for a message submission agent. 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @category Horde 19 * @copyright 2014-2016 Horde LLC 20 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 * @package Mail_Autoconfig 22 */ 23class Horde_Mail_Autoconfig_Server_Msa extends Horde_Mail_Autoconfig_Server 24{ 25 /** 26 * Default MSA port (RFC 6409). 27 */ 28 public $port = 587; 29 30 /** 31 */ 32 public function valid(array $opts = array()) 33 { 34 if (empty($opts['users']) || !isset($opts['auth'])) { 35 unset($opts['auth']); 36 $opts['users'] = array(null); 37 } 38 39 switch ($this->tls) { 40 case 'starttls': 41 $secure = 'tls'; 42 break; 43 44 case 'tls': 45 $secure = 'ssl'; 46 break; 47 48 default: 49 $secure = !empty($opts['insecure']) ?: 'tls'; 50 break; 51 } 52 53 foreach ($opts['users'] as $user) { 54 try { 55 $smtp = new Horde_Smtp(array( 56 'host' => $this->host, 57 'password' => isset($opts['auth']) ? $opts['auth'] : null, 58 'port' => $this->port, 59 'secure' => $secure, 60 'timeout' => 2, 61 'username' => $user 62 )); 63 $smtp->noop(); 64 65 if (isset($opts['auth'])) { 66 $this->username = $user; 67 } 68 69 if ($secure === 'tls') { 70 $this->tls = 'starttls'; 71 } elseif ($secure === true) { 72 $this->tls = $pop3->isSecureConnection() 73 ? 'starttls' 74 : false; 75 } 76 77 $smtp->shutdown(); 78 79 return true; 80 } catch (Horde_Smtp_Exception $e) {} 81 } 82 83 return false; 84 } 85 86} 87