'Heroku not delivering email through smtp

I have a server running on heroku and im trying to send emails through my app but I get an error saying smtp.googlemail.com failed, on localhost it works but on heroku doesn't, anyone encountered this error before?

   private fun sendEmail(destEmail: String, htmlMessage: String, subject: String) {
        val email = HtmlEmail()
        email.hostName = host
        email.setSmtpPort(hostPort)
        email.setAuthenticator(DefaultAuthenticator(hostSender, hostPassword))
        email.isSSLOnConnect = true
        email.setFrom(hostSender, "Safe&Sound")
        email.subject = subject
        email.setHtmlMsg(htmlMessage)
        email.addTo(destEmail)
        email.send()
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source