Forums / Setup & design / SMTP Authentication

SMTP Authentication

Author Message

Guido Faecke

Monday 02 April 2007 2:25:24 pm

Hi folks,

after spending 2 nights and today with getting SMTP for notification running i found a solution that is working for me.

Right now i'm running version 3.9.1 on an cpanel/redhat setup, and yes, i have root access.
it was easy for me to get the mail notification with sendmail working. but i usually set in cpanel/whm the sendmail option for php to false.
so i tried to get SMTP working... which was not so easy...
that is my working site.ini setting...

[MailSettings]
Transport=SMTP
AdminEmail=ezadmin@<my-domain>
EmailSender=ezadmin@<my-domain>
TransportServer=<my-mail-server>
TransportUser=<mail-user-name>
TransportPassword=<mail-user-password>

BUT... all i got was

[ Apr 02 2007 13:35:57 ] [x.x.x.x] eZSMTPTransport::sendMail():
Error sending SMTP mail: RCPT TO:<testuser9@xxxxx.xxx> command failed, output: 550-firstnetguard.com (mail.usa-info.net)
[x.x.x.x] is currently not
550-permitted to relay through this server. Perhaps you have not logged into
550-the pop/imap server in the last 30 minutes or do not have SMTP
550 Authentication turned on in your email client.
[ Apr 02 2007 13:35:57 ] [x.x.x.x] eZSMTPTransport::sendMail():
Error sending SMTP mail: DATA command failed, output: 503 valid RCPT command must precede DATA

For me the problem is the AUTH section is /lib/ezutils/classes/ezsmtp.php
While the original script is using the command "AUTH", my server reject this comand.
After i figured out that i need to send "AUTH PLAIN <login-data>" i changed the script from:

        function auth()
        {
            /* if the connection is made */
            if ( $this->send_cmd('AUTH', '334' ) )
            {
                /* if sending username ok */
                if ( $this->send_cmd( base64_encode( $this->user ), '334' ) )
                {
                    /* if sending password ok */
                    if ( $this->send_cmd( base64_encode( $this->pass ), '235' ) )
                    {
                        /* set the authenticated  flag and return TRUE */
                        $this->authenticated = TRUE;
                         return TRUE;
                    }
                }
            }
            /* in other case return FALSE */
            return FALSE;
        }

to:

        function auth()
        {
            /* if the connection is made */
            if ( $this->send_cmd('AUTH PLAIN ' . base64_encode( chr(0) . $this->user . chr(0) . $this->pass), '235' ) )
            {
                        /* set the authenticated  flag and return TRUE */
                        $this->authenticated = TRUE;
                         return TRUE;
            }
            /* in other case return FALSE */
            return FALSE;
        }

that works perfect for me!

I hope someone else can use this for a similar problem.
I know it's just a quick-and-dirty fix, but with a little more afford and 1 or 2 ini-settings, it could be usable for everybody who is using different AUTH methods.

See you,
Guido

my first ezPublish setup (test) ever with http://www.usa-info.net

Guido Faecke

Monday 02 April 2007 3:08:27 pm

so, i changed it a little bit more...

        function auth()
        {
            /* if the connection is made */
            /* changed from "AUTH" to "AUTH LOGIN" by G.Faecke */
            //if ( $this->send_cmd('AUTH', '334' ) )
            if ( $this->send_cmd('AUTH LOGIN', '334' ) )
            {
                /* if sending username ok */
                if ( $this->send_cmd( base64_encode( $this->user ), '334' ) )
                {
                    /* if sending password ok */
                    if ( $this->send_cmd( base64_encode( $this->pass ), '235' ) )
                    {
                        /* set the authenticated  flag and return TRUE */
                        $this->authenticated = TRUE;
                         return TRUE;
                    }
                }
            }
            /* added "AUTH PLAIN" by G.Faecke */
            if ( $this->send_cmd('AUTH PLAIN', '334' ) )
            {
                if ( $this->send_cmd( base64_encode( chr(0) . $this->user . chr(0) . $this->pass), '235' ) )
                {
                    /* set the authenticated  flag and return TRUE */
                    $this->authenticated = TRUE;
                    return TRUE;
                }
            }
            /* in other case return FALSE */
            return FALSE;
        }

I hope that's ok ;-)

Guido

my first ezPublish setup (test) ever with http://www.usa-info.net