Skip to content

Commit

Permalink
export SMTPError so it can be used in Send() to return custom smtp er…
Browse files Browse the repository at this point in the history
…rors
  • Loading branch information
nberlee authored and emersion committed Feb 22, 2019
1 parent 14578f1 commit 2babd40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (c *Conn) handleData(arg string) {
err := c.User().Send(c.msg.From, c.msg.To, c.msg.Reader)
io.Copy(ioutil.Discard, c.msg.Reader) // Make sure all the data has been consumed
if err != nil {
if smtperr, ok := err.(*smtpError); ok {
if smtperr, ok := err.(*SMTPError); ok {
code = smtperr.Code
msg = smtperr.Message
} else {
Expand Down
7 changes: 4 additions & 3 deletions data.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"io"
)

type smtpError struct {
// SMTPError specifies the error code and message that needs to be returned to the client
type SMTPError struct {
Code int
Message string
}

func (err *smtpError) Error() string {
func (err *SMTPError) Error() string {
return err.Message
}

var ErrDataTooLarge = &smtpError{
var ErrDataTooLarge = &SMTPError{
Code: 552,
Message: "Maximum message size exceeded",
}
Expand Down

0 comments on commit 2babd40

Please sign in to comment.