FAQ
So have been playing around with go and the net/smtp package to create a
program than can run some internal mailflow tests and come across an issue
with the way Hello function works.

The current function tries to be clever and if ehlo fails with error tries
the helo BUT the test I was performing was on a HELO check on an MTA that
dropped the connetion if EHLO/HELO met certain conditions. This had the
effect of making the call to ehlo fail, AND also the corresponding call to
helo (EOF) since connection is dropped. The error returned to the calling
function though is that of the helo rather than the ehlo call and as such
does not send back what the remote MTA had to say originally

func (c *Client) hello() error {
         if !c.didHello {
                 c.didHello = true
                 err := c.ehlo()
                 if err != nil { // fails
here
                         c.helloError = c.helo() // sets helloError
here .. BUT wrong one
                 }
         }
         return c.helloError
}

updated to function to

func (c *Client) hello() error {
         if !c.didHello {
                 c.didHello = true
                 err := c.ehlo()
                 if err != nil {
                         c.helloError = c.helo()
                         // if there is an error AND that error is io.EOF
then let c.helloError = the initial error
                         if c.helloError != nil && c.helloError == io.EOF {
                                 c.helloError = err
                         }
                 }
         }
         return c.helloError
}

Given just started the GO journey not sure if this is the best way to
handle it but certainly spits back the correct output from remote MTA on
the original ehlo call rather than EOF from the secondary helo call ....


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 9, '15 at 3:58a
activeOct 9, '15 at 3:58a
posts1
users1
websitegolang.org

1 user in discussion

Matt Bryant: 1 post

People

Translate

site design / logo © 2022 Grokbase