net/smtp Quit should prolly have a better return value

185 views
Skip to first unread message

Christian Schmitt

unread,
Jun 29, 2015, 11:27:06 AM6/29/15
to golan...@googlegroups.com
Hello currently I struggled to keep my webserver up after sending a mail,
that was caused since I had something like that in my code:

if err = c.Quit(); err != nil {
log.Fatal(err)
}

I kept searching and if read the Docs so carefully.. (https://golang.org/pkg/net/smtp/#Client.Quit)

However Quit() doesn't return just an error as it seems...

We should prolly fix that to standard go like (string, error). Since the 250 Ok Message of the Client will also be an error, which is of course not an error and it will shut your program down, if you check for an error..

Andrew Gerrand

unread,
Jun 30, 2015, 8:14:37 AM6/30/15
to Christian Schmitt, golang-nuts
Hi Christian,

Why would the 250 OK message from the client be an error?

I'm reading the code, and I don't see anything but actual errors being returned by Quit.

What am I missing?

Andrew



--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Schmitt

unread,
Jun 30, 2015, 8:18:37 AM6/30/15
to golan...@googlegroups.com, c.sc...@briefdomain.de
I used it with AWS SES and It returned the following:

    14:17:30 app         | 2015/06/30 14:17:30 Quit Message: 250 Ok 0000014e44669548-f3afa74a-3a31-41ea-b2c6-f7a61b9f63e9-000000

Currently this is my code:


I'm not sure but 250 Ok doesn't seems to be an error...

Bruno Albuquerque

unread,
Jun 30, 2015, 8:25:38 AM6/30/15
to Christian Schmitt, golan...@googlegroups.com
Quit seems to expect code 221 and, if I understand the code, everything else is considered an error. So 250 is an error.

This looks like a bug.

Christian Schmitt

unread,
Jun 30, 2015, 8:29:56 AM6/30/15
to golan...@googlegroups.com, b...@bug-br.org.br
Looks like that happens when you don't call w.Close.. 
Sorry looks like my fault.

Bruno Albuquerque

unread,
Jun 30, 2015, 8:30:12 AM6/30/15
to Christian Schmitt, golan...@googlegroups.com
FYI.

Looking at the RFC (https://tools.ietf.org/html/rfc821), it looks like the SMTP server being used is at fault. It should not reply with code 250 when it gets a QUIT command. It should be 221.

Reply all
Reply to author
Forward
0 new messages