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


Reply via email to