英文:
Sending a mail with net/smtp through http CONNECT proxy
问题
我的Go程序使用net/smtp
库发送邮件。
client, err := smtp.Dial(addr)
当连接到SMTP服务器时,我想通过基于HTTP CONNECT的代理进行传递。
英文:
My Go program sends a mail with the net/smtp
library.
client, err := smtp.Dial(addr)
When connecting to the SMTP server I would like to pass through a HTTP CONNECT-based proxy.
答案1
得分: 1
要通过CONNECT代理发送SMTP流量,您需要使用smtp.NewClient(conn net.Conn, host string)
并提供一个现有连接(net.Conn
)到您的CONNECT代理。
magisterquis/connectproxy
包很可能是您需要创建此连接的工具:
d, err := connectproxy.New("https://proxyserver:4433", proxy.Direct)
if nil != err{
panic(err)
}
c, err := d.Dial("tcp", "upstream.mail.server:25")
if nil != err {
panic(err)
}
smtpClient, err := smtp.NewClient(c, "upstream.mail.server")
if nil != err {
panic(err)
}
英文:
To send SMTP traffic via a CONNECT proxy, you'll need to make use of smtp.NewClient(conn net.Conn, host string)
with an existing connection (net.Conn
) to your CONNECT proxy.
The magisterquis/connectproxy
package is most likely be what you will need to create this connection:
d, err := connectproxy.New("https://proxyserver:4433", proxy.Direct)
if nil != err{
panic(err)
}
c, err := d.Dial("tcp", "upstream.mail.server:25")
if nil != err {
panic(err)
}
smtpClient, err := smtp.NewClient(c, "upstream.mail.server")
if nil != err {
panic(err)
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论