Re: [go-nuts] Read multiline error response from smtp.SendMail

197 views
Skip to first unread message

Dave Cheney

unread,
Feb 6, 2013, 5:10:28 PM2/6/13
to Everton Marques, golang-nuts

What happens when you print the original text from err.Error() ?

On 7 Feb 2013 03:53, "Everton Marques" <everton...@gmail.com> wrote:
Hi,

I am using this code:

err := smtp.SendMail(
smtpHostPort,
auth,
sender,
[]string{recipient},
[]byte(message),
)
if err != nil {
log.Printf("sendSmtp: failure: %q", strings.Split(err.Error(), "\n"))
}

However the multiline error response seems truncated:

2013/02/06 11:54:41 sendSmtp: failure: ["530 5.5.1 Authentication Required. Learn more at"]

How can I get the full multiline error response?

Thanks,
Everton

--
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/groups/opt_out.
 
 

Everton Marques

unread,
Feb 7, 2013, 3:43:16 PM2/7/13
to golan...@googlegroups.com, Everton Marques
Pretty much the same:

//log.Printf("sendSmtp: failure: %q", strings.Split(err.Error(), "\n"))
log.Printf("sendSmtp: failure: (%s)", err.Error())

2013/02/07 18:40:40 sendSmtp: failure: (530 5.5.1 Authentication Required. Learn more at)

Dave Cheney

unread,
Feb 8, 2013, 12:21:01 AM2/8/13
to Everton Marques, golan...@googlegroups.com
Sounds like the error message is truncated when it is generated. It
probably looks like this on the wire:

530 5.1.1 Authentication Required. Learn more at
530 5.1.1 tehsecures.derp.com. Alternatively you can
530 5.1.1 receive this error by dialing 9 on your touch
530 5.1.1 phone keypad.

I don't know how to fix this, or if it is valid RFC 821.

Everton Marques

unread,
Feb 8, 2013, 11:08:11 AM2/8/13
to golan...@googlegroups.com, Everton Marques
As far as I could trace from the source, smtp.SendMail eventually calls (indirectly) textproto.ReadResponse to read the multiline response.
Then textproto.ReadResponse is expected to return the full multiline response.


textproto.ReadResponse from: golang.org/src/pkg/net/textproto/reader.go

May this be a bug?
Reply all
Reply to author
Forward
0 new messages