Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting authType type #40

Closed
LordNoteworthy opened this issue Jun 22, 2021 · 3 comments
Closed

Exporting authType type #40

LordNoteworthy opened this issue Jun 22, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@LordNoteworthy
Copy link

Hello @xhit

First, thanks for the package !

Would it make sense to make the type type authType public like what you have done for Encryption?

So in a method which creates the SMTP client could take the authType as string then cast it to authType.

Cheers.

@xhit
Copy link
Owner

xhit commented Jun 22, 2021

Yes, make sense that change.

If you want to share a PR I will take a look in next hours. If not, I will commit the changes this night.

@xhit xhit added the enhancement New feature or request label Jun 22, 2021
@xhit xhit closed this as completed in 7bddd91 Jul 7, 2021
@xhit
Copy link
Owner

xhit commented Jul 7, 2021

Done. Now you can use a func like this:

func AuthTypeFromString(authType string) (mail.AuthType, error) {
	switch {
	case strings.EqualFold(authType, "none"):
		return mail.AuthNone, nil
	case strings.EqualFold(authType, "plain"):
		return mail.AuthPlain, nil
	case strings.EqualFold(authType, "login"):
		return mail.AuthLogin, nil
	case strings.EqualFold(authType, "cram-md5"):
		return mail.AuthCRAMMD5, nil
	}

	return mail.AuthNone, fmt.Errorf(`invalid authentication type "%s"`, authType)
}

@LordNoteworthy
Copy link
Author

Thank you so much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants