Skip to content

Commit

Permalink
Use int64 for MailOptions.Size
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Aug 14, 2023
1 parent 8b38375 commit 7a3ee4f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type MailOptions struct {
Body BodyType

// Size of the body. Can be 0 if not specified by client.
Size int
Size int64

// TLS is required for the message transmission.
//
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (c *Client) Mail(from string, opts *MailOptions) error {
cmdStr += " BODY=8BITMIME"
}
if _, ok := c.ext["SIZE"]; ok && opts != nil && opts.Size != 0 {
cmdStr += " SIZE=" + strconv.Itoa(opts.Size)
cmdStr += fmt.Sprintf(" SIZE=%v", opts.Size)
}
if opts != nil && opts.RequireTLS {
if _, ok := c.ext["REQUIRETLS"]; ok {
Expand Down
10 changes: 5 additions & 5 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Conn struct {
bdatPipe *io.PipeWriter
bdatStatus *statusCollector // used for BDAT on LMTP
dataResult chan error
bytesReceived int // counts total size of chunks when BDAT is used
bytesReceived int64 // counts total size of chunks when BDAT is used

fromReceived bool
recipients []string
Expand Down Expand Up @@ -321,12 +321,12 @@ func (c *Conn) handleMail(arg string) {
return
}

if c.server.MaxMessageBytes > 0 && int(size) > c.server.MaxMessageBytes {
if c.server.MaxMessageBytes > 0 && size > c.server.MaxMessageBytes {
c.writeResponse(552, EnhancedCode{5, 3, 4}, "Max message size exceeded")
return
}

opts.Size = int(size)
opts.Size = size
case "SMTPUTF8":
if !c.server.EnableSMTPUTF8 {
c.writeResponse(504, EnhancedCode{5, 5, 4}, "SMTPUTF8 is not implemented")
Expand Down Expand Up @@ -676,7 +676,7 @@ func (c *Conn) handleBdat(arg string) {
return
}

if c.server.MaxMessageBytes != 0 && c.bytesReceived+int(size) > c.server.MaxMessageBytes {
if c.server.MaxMessageBytes != 0 && c.bytesReceived+int64(size) > c.server.MaxMessageBytes {
c.writeResponse(552, EnhancedCode{5, 3, 4}, "Max message size exceeded")

// Discard chunk itself without passing it to backend.
Expand Down Expand Up @@ -746,7 +746,7 @@ func (c *Conn) handleBdat(arg string) {
return
}

c.bytesReceived += int(size)
c.bytesReceived += int64(size)

if last {
c.lineLimitReader.LineLimit = c.server.MaxLineLength
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Server struct {

Domain string
MaxRecipients int
MaxMessageBytes int
MaxMessageBytes int64
MaxLineLength int
AllowInsecureAuth bool
Debug io.Writer
Expand Down

0 comments on commit 7a3ee4f

Please sign in to comment.