mailhog / MailHog

Web and API based SMTP testing
MIT License
13.98k stars 1.06k forks source link

Mailhog timeout issue #277

Open nibro7778 opened 4 years ago

nibro7778 commented 4 years ago

We have hosted mailhog client and SMTP via docker to one of the instances on a cloud. We are facing a timeout issue when we are trying to send an email with attachments and total attachment size is more than 4.5 MB

The same attachments file are working fine when we are sending an email to the localhost instance of mailhog server but the same attachments file we are not able to send it to cloud mailhog server instance. we tried to send a plain text email to the mailhog cloud instance and it was working fine. so, mailhog is set up properly.

Also, sometimes we are getting the following error

Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.

It seems like some connection issue or Is there any configuration that can resolve the timeout issue or I missed some configuration or something wrong with cloud mailhog instance.

nibro7778 commented 4 years ago

Any update on the above issue?

suside commented 4 years ago

I had timeout issues during logging in, after some debugging I found a workaround. You can try to replace this: https://github.com/mailhog/MailHog/blob/f5559ac00323e7f2ab5abcea3628e0c492bb3bf2/vendor/github.com/mailhog/MailHog-Server/smtp/session.go#L155-L162 with:


func (c *Session) Write(reply *smtp.Reply) {
    replyBody := strings.Join(reply.Lines(), "")
    n, err := c.writer.Write([]byte(replyBody))
    if err != nil {
        c.logf("Error writing to socket: ", err)
    } else {
        c.logf("Sent %d bytes: '%s'", n, strings.TrimSpace(replyBody))
    }
}