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

Why is it not possible to use proxy? #79

Closed
awiz911 opened this issue May 22, 2023 · 4 comments
Closed

Why is it not possible to use proxy? #79

awiz911 opened this issue May 22, 2023 · 4 comments

Comments

@awiz911
Copy link

awiz911 commented May 22, 2023

I saw question and comment about proxy in closed issue.

However it's not a network issue.

With "net/smtp" and "golang.org/x/net/proxy" we can easily create smtpClient through proxy:

Dial, err := proxy.SOCKS5("tcp", "some-proxy-address", nil, proxy.Direct)
if err != nil {
	return nil, errors.Wrap(err, "Create SOCKS5")
}

dialer, err = Dial.Dial("tcp", "host-addr")
if err != nil {
	return nil, errors.Wrap(err, "Dial")
}

conf := &tls.Config{ServerName: "host-addr-without-port"}
tlsdialer := tls.Client(dialer, conf)

client, err := smtp.NewClient(tlsdialer, "host-addr")
if err != nil {
	panic(err)
}

auth := smtp.PlainAuth("", user, pass, "host-addr")
if err = client.Auth(auth); err != nil {
	panic(err)
}

And would be awesome if smth like this would be possible in this package. Cuz it's quite convient for sending mail.
Or if it's too much trouble, then why was smtpClient made not exportable in the first place. It has couple slight differences with net's smtp.Client type: there's a instead of auth and Text made exportable.
If instead of creating separate type net's smtp.Client was used then we would have proxy as in code above.
Even if there's a different type, then methods to change connections would work too.

Or add couple params to SMTPServer type for proxy and on connect if there are filled in use them for connection.
So many ways to do it. Wander why it wasn't done in the first place. (

@xhit
Copy link
Owner

xhit commented May 22, 2023

(sorry for my bad English)

Hi Aleksey, thanks for your share your thoughs.

In that moment, 2021, I only had this package for some internal uses in the company, so any proposed change that wasn't required was rejected and I apologize for that.

At this moment, this package is open to any change that will be useful for anyone. That's why I create the v3 branch to allow contributors the changes that will be a breaking change like make a exportable smtpClient, func name changes, etc...

Currently I'm connected to check it every night, but I paused the development by me to concentrate in other projects. So, if you have a change that is a breaking change, use v3 branch, otherwise, the master branch as the destination branch for your PR.

I can make this happens, but I will not compromise for a short time.

I will left this issue opened and pinned, although I don´t receive PR, is in my TODO list.

Thanks.

@awiz911
Copy link
Author

awiz911 commented May 22, 2023

Your english is fine. )

I might just do that actually. Will get payed for it too. ))) Without this package would have to pretty much make my own from scratch for project I'm working on. So this seems like a faster way to finish. )))

@xhit xhit pinned this issue May 22, 2023
@xhit xhit closed this as completed in 457c8da Jul 7, 2023
@xhit
Copy link
Owner

xhit commented Jul 7, 2023

Hi @awiz911, now you can use a your custom connection https://github.com/xhit/go-simple-mail#send-with-custom-connection

Sorry for delay, thanks for the motivation 🚀

@xhit xhit unpinned this issue Jul 7, 2023
@awiz911
Copy link
Author

awiz911 commented Jul 8, 2023

@xhit I'm the one who should be sorry. ( Got caught up with work projects and code-contests and didn't find time to add solution myself. ( Thanks for great lib and great work.

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

No branches or pull requests

2 participants