Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mms] Added an LMTP (RFC 2033) driver.
[mms] Horde_Smtp#send() now returns recipient status information if at least one recipient was successfully accepted.
- Loading branch information
Showing
5 changed files
with
228 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* Copyright 2014 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @copyright 2014 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Smtp | ||
*/ | ||
|
||
/** | ||
* An interface to an LMTP server (RFC 2033). | ||
* | ||
* @todo If/when CHUNKING is supported in base driver, RFC 2033 [4.3] (BDAT | ||
* command) needs to be implemented here. | ||
* | ||
* @author Michael Slusarz <slusarz@horde.org> | ||
* @category Horde | ||
* @copyright 2014 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Smtp | ||
* @since 1.5.0 | ||
*/ | ||
class Horde_Smtp_Lmtp extends Horde_Smtp | ||
{ | ||
/** | ||
* LMTP only supports LHLO hello command (RFC 2033 [4.1]), not EHLO. | ||
* | ||
* HELO isn't supported, but HELO code in _hello() should not be reached | ||
* since failure of LHLO command will result in 500 error code (instead | ||
* of 502 necessary to fallback to HELO). | ||
*/ | ||
protected $_ehlo = 'LHLO'; | ||
|
||
/** | ||
* These extensions are required for LMTP (RFC 2033 [5]). | ||
*/ | ||
protected $_requiredExts = array( | ||
'ENHANCEDSTATUSCODES', | ||
'PIPELINING' | ||
); | ||
|
||
/** | ||
*/ | ||
public function __construct(array $params = array()) | ||
{ | ||
// LMTP MUST NOT be on port 25 (RFC 2033 [5]). | ||
if (isset($params['port']) && ($params['port'] == 25)) { | ||
throw new InvalidArgumentException( | ||
'Cannot use port 25 for a LMTP server.' | ||
); | ||
} | ||
|
||
parent::__construct($params); | ||
} | ||
|
||
/** | ||
*/ | ||
protected function _processData($recipients) | ||
{ | ||
/* RFC 2033 [4.2]: there is one response for each successful | ||
* recipient, so need to iterate through the array. If no successful | ||
* recipients found, throw an exception. */ | ||
$out = array(); | ||
$success = false; | ||
|
||
foreach ($recipients as $val) { | ||
try { | ||
$this->_getResponse(250); | ||
$out[$val] = $success = true; | ||
} catch (Horde_Smtp_Exception $e) { | ||
$out[$val] = $e; | ||
} | ||
} | ||
|
||
if (!$success) { | ||
$e = new Horde_Smtp_Exception('Sending to all recipients failed.'); | ||
$e->setSmtpCode(550); | ||
throw $e; | ||
} | ||
|
||
return $out; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters