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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 22:20:22
Script start
Timing: Jan 18 2025 22:20:22
Module start 'layout'
Timing: Jan 18 2025 22:20:22
Module start 'content'
Timing: Jan 18 2025 22:20:22
Module end 'content'
Timing: Jan 18 2025 22:20:22
Script end

Main resources:

Total runtime0.7340 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.3359152.6250
Module start 'layout' 0.00660.0027 741.960939.4297
Module start 'content' 0.00930.7232 781.3906477.6406
Module end 'content' 0.73250.0015 1,259.031312.1875
Script end 0.7340  1,271.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4321160.0002
Check MTime0.00130.1766160.0001
Mysql Total
Database connection0.00160.213510.0016
Mysqli_queries0.688093.7263520.0132
Looping result0.00040.0567500.0000
Template Total0.703195.820.3515
Template load0.00200.277120.0010
Template processing0.701095.499120.3505
Template load and register function0.00010.015310.0001
states
state_id_array0.00090.123010.0009
state_identifier_array0.00110.148220.0005
Override
Cache load0.00160.2219410.0000
Sytem overhead
Fetch class attribute can translate value0.00060.087610.0006
Fetch class attribute name0.00090.121420.0004
XML
Image XML parsing0.00010.013910.0001
class_abstraction
Instantiating content class attribute0.00000.000720.0000
General
dbfile0.00070.0923100.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs