2

i'm using gomail v2 to send email to my member and then using docker to run my service.

but when i hit the api that host my sendemail function i get this error

dial tcp: i/o timeout

here's my code

func (cc *UserController) ForgetPassword(ctx *gin.Context)  {



    msg := "forget pass link: forgetpasslink.com"

    mailer := gomail.NewMessage()
    mailer.SetHeader("From", "thisemail@gmail.com")
    mailer.SetHeader("To", "targetemail@gmail.com")
    mailer.SetAddressHeader("Cc", "adminapp@gmail.com", "ADMIN")
    mailer.SetHeader("Subject", "test email")
    mailer.SetBody("text/plain", msg)

    dialer := gomail.NewDialer(
        "smtp.google.com",
        587,
        "thisemail@gmail.com",
        "emailpass",
    )

    err = dialer.DialAndSend(mailer)

    if err != nil {
        ctx.JSON(http.StatusBadRequest, err.Error())
        return
    }

    return
}

1 Answers1

0

Seems to be a problem running it in docker or ubuntu. (https://github.com/go-gomail/gomail/issues/80 -- though the linked issue is from 2017...)

I am working on an application where it runs fine locally, but I get the same dial tcp //ip i/o timeout when deployed via docker on a ubuntu server.

When I comment out the mail functionality, it works fine.

Can you let us know if you came up with a solution?