I've got a G Suite account set up and I enabled the SMTP relay service. The relay service is currently configured to accept mail from my webservers IP address only, not requiring SMTP authentication or TLS encryption.
This link tells me that I should be able to send mail to smtp-relay.gmail.com on port 25 (or 465/587).
That's all well and good. I've got a very simple go script to send email here.
package main
import (
"log"
"net/smtp"
"os"
)
func main() {
args := os.Args[1:]
to := args[0]
body := args[1]
from := "[my g-suite user account name]"
msg := "From: " + from + "
" + "To: " + to + "
" +
"Subject: Hello Friend
" + body
err := smtp.SendMail("smtp-relay.gmail.com:25",nil,
from, []string{to}, []byte(msg))
if err != nil {
log.Printf("smtp err :%s
",err)
} else {
log.Printf("Email sent
")
}
log.Printf("email sent
")
}
When I run this, I get the following panic
2018/11/29 12:24:22 smtp err :dial tcp 74.125.195.28:25: connect: no route to host
I understand what this error is telling me but I cant for the life of me resolve it. I thought it was a problem with my firewall settings. I've tried flushing my iptables and disabling ufw but I get the same result every time.
I've also tried sending mail from this webserver using mutt and sendmail (with similar settings).
Any suggestions on what I should be looking for? I have done a bunch of searching and tried several other scripts but always have the same result.
EDIT
After trying a few different options like regular gmail with an existing account, using sendmail or ssmtp I looked at tcpdump while trying to send mail. Wireshark shows that the communication with the mail server as "Communication administratively filtered". I'm taking that to mean the hosting provider is filtering ports 25,465 and 587 since I've tried them all and I've disabled my rules.