emersion / go-smtp

📤 An SMTP client & server library written in Go
MIT License
1.72k stars 216 forks source link

google smtp fails to send message with error `Relay access denied` #224

Closed rew1nter closed 1 year ago

rew1nter commented 1 year ago

I used the example receiver snippet from repo then replaced the domain name with my domain and port with :25. Upon sending an email from gmail client, I get this error:

Your message couldn't be delivered to x@mydomain.com because the remote server is misconfigured
...
This response from the remote server was:
5554 5.7.1 <x@mydomain.com>: Relay access denined

I also tried it like this by removing the auth part but no luck:

func (s *Session) AuthPlain(username, password string) error {
    // if username != "username" || password != "password" {
    //  return errors.New("Invalid username or password")
    // }
    return nil
}
rew1nter commented 1 year ago

I didn't set the mx records. The error was caused by that