Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tiptenbrink
Copy link

@tiptenbrink tiptenbrink commented Sep 7, 2025

Tested with a Google Workspace SMTP relay. Since that uses IP address authentication, we don't directly do smtp.Dial, since then the local name is set to localhost. Instead, we use net.Dial so we get the connection struct from which we can actually get the local address hostname and then do client.Hello to actually set it. Don't know why Go doesn't do this by default, Python worked fine and took forever to find out why Go wasn't working.

Somewhat opinionated since I assume TLS is required. I think it's best to leave that as the default. Messages are super simple, but do use the time and displayName if it is set.

@pilcrowonpaper
Copy link
Contributor

I might be missing something but the code you wrote seems the exact same as smtp.Dial()?

https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/net/smtp/smtp.go;drc=2ef8e41f9543478a51a0147a735e4415737de09f;l=53

I think the actual issue is that you just need to call Hello() manually?

https://pkg.go.dev/net/smtp#Client.Hello

@tiptenbrink
Copy link
Author

I might be missing something but the code you wrote seems the exact same as smtp.Dial()?

https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/net/smtp/smtp.go;drc=2ef8e41f9543478a51a0147a735e4415737de09f;l=53

I think the actual issue is that you just need to call Hello() manually?

https://pkg.go.dev/net/smtp#Client.Hello

Indeed, but the argument for Hello() should be your local address host name, which you can't get from the smtp client object struct returned by smtp.Dial(). If you establish the connection yourself, as I did in my code, you can easily get this address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants