I am trying to send an email using Go. however I try to use my host custom mail servers wich are the followings
So I am not quite sure what should I use over here. I am doing the following
auth := smtp.PlainAuth("", "noreply@icon-universe.com", "password", "mail.icon-universe.com")
log.Println(smtp.SendMail("mail.icon-universe.com:25", auth, "noreply@icon-universe.com", []string{"to@gmail.com"}, []byte("This is a simple test")))
However this would give me the following error
x509: certificate is valid for server.premierehost.net, www.server.premierehost.net, not mail.icon-universe.com
So then I tried the following
auth := smtp.PlainAuth("", "noreply@icon-universe.com", "password", "server.premierehost.net")
log.Println(smtp.SendMail("server.premierehost.net:465", auth, "noreply@icon-universe.com", []string{"nakotoffana@gmail.com"}, []byte("thanks for loggin in")))
However this would just make my app go on an infinite loop...
Wich connection details should I use?
--- Update
I decided to try go-mail and seems to work but not for @gmail
d := gomail.NewDialer("server.premierehost.net", 465, "noreply@icon-universe.com", "password")
m := gomail.NewMessage()
m.SetHeader("From", "noreply@icon-universe.com")
m.SetHeader("To", "carvajal@karmagameworks.com")
m.SetHeader("Subject", "Hello!")
m.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
log.Println(d.DialAndSend(m))
This will work and the email will appear but sending to @gmail.com wont (the email will never arrive)