Looking at the code below, and the C code I wrote for SASL
authentication in Postfix, I am not confident that sufficient code would
be shared to justify the complexity of creating a component to export
APIs to these different components, although I can imagine a "helper"
class might contain a small amount of common code, especially if we
created something vaguely like a fly-weight version of the "expect"
language. Regardless, my recent experience with Zend_Session* classes
went the opposite direction, by carefully segmenting APIs and publishing
them only for consumption by the intended classes, without polluting
APIs with irrelevant methods, using superclasses with protected methods.
If PHP had more robust syntactical methods for isolating methods of a
class and exporting them only to selected classes, then the situation
would be different.
I trust Justin's working code is better than what we have now (nothing),
and I personally will need this functionality, so I am hoping Justin
will sign our CLA and contribute the code. There would be plenty of
opportunities to examine options and alternative ways of using this code :)
Cheers,
Gavin
Nico Edtinger wrote:
Maybe we could create a seperate class for auth methods so we can use
them with POP3 and IMAP too.
nico
[01.02.2007 23:10] Gavin Vess wrote:
Moving discussion to fw-formats list ...
Hi Justin,
Would you like to sign our CLA and create an issue in our issue
tracker with this patch?
http://framework.zend.com/wiki/display/ZFPROP/Contributor+License+Agreement
http://framework.zend.com/issues/secure/Dashboard.jspa
Thanks!
Gavin
Justin Hendrickson wrote:
I wrote this a few weeks back and it seems to be working alright. It
only supports AUTH LOGIN and AUTH PLAIN though.
<?php
require_once 'Zend/Mail/Transport/Smtp.php';
class My_Zend_Mail_Transport_Smtp_Auth extends
Zend_Mail_Transport_Smtp {
/[EMAIL PROTECTED]
* Authentication types
* @var string
*/
const LOGIN = 'LOGIN';
const PLAIN = 'PLAIN';
/[EMAIL PROTECTED]/
/**
* @param string $username
* @param string $password
* @param string $method
*/
protected function authenticate($username, $password, $method =
self::PLAIN) {
switch($method) {
case self::LOGIN:
$this->authenticateLogin($username, $password);
break;
case self::PLAIN:
$this->authenticatePlain($username, $password);
break;
}
}
/**
* @param string $username
* @param string $password
* @throws Zend_Mail_Transport_Exception
*/
protected function authenticateLogin($username, $password) {
$this->_send('AUTH LOGIN');
try {
$this->_expect(334);
} catch(Zend_Mail_Transport_Exception $e) {
if(substr($e->getMessage(), 0, 3) == 503) {
return;
}
throw $e;
}
$this->_send(base64_encode($username));
$this->_expect(334);
$this->_send(base64_encode($password));
$this->_expect(235);
}
/**
* @param string $username
* @param string $password
* @throws Zend_Mail_Transport_Exception
*/
protected function authenticatePlain($username, $password) {
$this->_send('AUTH PLAIN');
try {
$this->_expect(334);
} catch(Zend_Mail_Transport_Exception $e) {
if(substr($e->getMessage(), 0, 3) == 503) {
return;
}
throw $e;
}
$this->_send(base64_encode(chr(0) . $username . chr(0) .
$password));
$this->_expect(235);
}
}
On 1/31/07, *Sanjay Aggarwal* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Right Now SMTP authentication is not there in the mail class. Is
there anyone who has implemented SMTP authentication with Zend
Framework any how? If so - do let me know asap. That will be a
great help for us.
Regards,
Sanjay Aggarwal
--Cheers,
Gavin
Which ZF List?
=================
Everything, except the topics below: [email protected]
Authorization, Authentication, ACL, Access Control, Session Management
[EMAIL PROTECTED]
Tests, Caching, Configuration, Environment, Logging
[EMAIL PROTECTED]
All things related to databases
[EMAIL PROTECTED]
Documentation, Translations, Wiki Manual / Tutorials
[EMAIL PROTECTED]
Internationalization & Localization, Dates, Calendar, Currency, Measure
[EMAIL PROTECTED]
Mail, MIME, PDF, Search, data formats (JSON, ...)
[EMAIL PROTECTED]
MVC, Controller, Router, Views, Zend_Request*
[EMAIL PROTECTED]
Community Servers/Services (shell account, PEAR channel, Jabber)
[EMAIL PROTECTED]
Web Services & Servers (HTTP, SOAP, Feeds, XMLRPC, REST)
[EMAIL PROTECTED]
How to un/subscribe: http://framework.zend.com/wiki/x/GgE
--
Cheers,
Gavin
Which ZF List?
=================
Everything, except the topics below: [email protected]
Authorization, Authentication, ACL, Access Control, Session Management
[EMAIL PROTECTED]
Tests, Caching, Configuration, Environment, Logging
[EMAIL PROTECTED]
All things related to databases
[EMAIL PROTECTED]
Documentation, Translations, Wiki Manual / Tutorials
[EMAIL PROTECTED]
Internationalization & Localization, Dates, Calendar, Currency, Measure
[EMAIL PROTECTED]
Mail, MIME, PDF, Search, data formats (JSON, ...)
[EMAIL PROTECTED]
MVC, Controller, Router, Views, Zend_Request*
[EMAIL PROTECTED]
Community Servers/Services (shell account, PEAR channel, Jabber)
[EMAIL PROTECTED]
Web Services & Servers (HTTP, SOAP, Feeds, XMLRPC, REST)
[EMAIL PROTECTED]
How to un/subscribe: http://framework.zend.com/wiki/x/GgE