[GH-ISSUE #11] Expose configuration for authentication #4

Closed
opened 2026-09-29 12:58:31 +00:00 by slurdge · 3 comments
Owner

Originally created by @dfosas on GitHub (Jan 22, 2022).
Original GitHub issue: https://github.com/slurdge/goeland/issues/11

Originally assigned to: @slurdge on GitHub.

I have been playing with this fantastic project but it took me a while to get it working with a particular smtp server. It seemed to boil down to authentication options. It seems like AuthPlain is the default but the underlying package allows for other options, needing AuthLogin in my case.

I have no idea of go or smtp, but I got to a minimal working example with the following additions to run.go by looking at the surrounding code:

authentications := map[string]email.AuthType{"plain": email.AuthPlain, "login": email.AuthLogin, "crammd5": email.AuthCRAMMD5}
authentication, found := authentications[config.GetString("email.auth")]
if !found {
    authentication = email.AuthPlain
}
server.Authentication = authentication

which allows configuration files to have an email.auth field.

Happy to do a pull request as per the contributing guidelines with that change and updating the documentation if that sounds sensible, but I am afraid I do not know how to go about tests here.

Many thanks!

Originally created by @dfosas on GitHub (Jan 22, 2022). Original GitHub issue: https://github.com/slurdge/goeland/issues/11 Originally assigned to: @slurdge on GitHub. I have been playing with this fantastic project but it took me a while to get it working with a particular smtp server. It seemed to boil down to authentication options. It seems like `AuthPlain` is the default but the underlying package allows for other options, needing `AuthLogin` in my case. I have no idea of go or smtp, but I got to a minimal working example with the following additions to [run.go](https://github.com/slurdge/goeland/blob/master/cmd/run.go#L61) by looking at the surrounding code: ```go authentications := map[string]email.AuthType{"plain": email.AuthPlain, "login": email.AuthLogin, "crammd5": email.AuthCRAMMD5} authentication, found := authentications[config.GetString("email.auth")] if !found { authentication = email.AuthPlain } server.Authentication = authentication ``` which allows configuration files to have an `email.auth` field. Happy to do a pull request as per the contributing guidelines with that change and updating the documentation if that sounds sensible, but I am afraid I do not know how to go about tests here. Many thanks!
Author
Owner

@slurdge commented on GitHub (Jan 22, 2022):

Hey,
Thanks for the report and for the kind words. It's really appreciated.

Your patch seems about right! The only thing I would add is also that the option is defaulted also in the viper config:

viper.SetDefault("email.authentication", "plain")

And also add "none"=>"AuthNone" for those who wish no auth (I'm not sure of the use case but maybe for SMTP behind firewalls...)

If you wish to do a PR that's absolutely fine by me. I prefer you get the credit for this patch, it's a great find!

As for the tests, I didn't take the time to properly do it... Especially with this piece of software since it's mainly related to connecting to real world servers.

Thanks!

<!-- gh-comment-id:1019367831 --> @slurdge commented on GitHub (Jan 22, 2022): Hey, Thanks for the report and for the kind words. It's really appreciated. Your patch seems about right! The only thing I would add is also that the option is defaulted also in the viper config: ```go viper.SetDefault("email.authentication", "plain") ``` And also add "none"=>"AuthNone" for those who wish no auth (I'm not sure of the use case but maybe for SMTP behind firewalls...) If you wish to do a PR that's absolutely fine by me. I prefer you get the credit for this patch, it's a great find! As for the tests, I didn't take the time to properly do it... Especially with this piece of software since it's mainly related to connecting to real world servers. Thanks!
Author
Owner

@dfosas commented on GitHub (Jan 23, 2022):

Fantastic. See pull request, hopefully that is all correct. Thanks!

<!-- gh-comment-id:1019549799 --> @dfosas commented on GitHub (Jan 23, 2022): Fantastic. See pull request, hopefully that is all correct. Thanks!
Author
Owner

@slurdge commented on GitHub (Jan 23, 2022):

👍 Should be good, publishing v0.9.0 right now

<!-- gh-comment-id:1019562721 --> @slurdge commented on GitHub (Jan 23, 2022): 👍 Should be good, publishing v0.9.0 right now
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: slurdge/goeland#4
No description provided.