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

net/smtp: No way to use other host name than "localhost" with helo command in smtp #33623

Closed
MBakhshi96 opened this issue Aug 13, 2019 · 1 comment

Comments

@MBakhshi96
Copy link

net/smtp always uses localhost with helo command, and since localname in not exported in Client struct, you can't change it not to use localhost. Here you can find Client struct inside net/smtp/smtp.go :

// A Client represents a client connection to an SMTP server.
type Client struct {
	// Text is the textproto.Conn used by the Client. It is exported to allow for
	// clients to add extensions.
	Text *textproto.Conn
	// keep a reference to the connection so it can be used to create a TLS
	// connection later
	conn net.Conn
	// whether the Client is using TLS
	tls        bool
	serverName string
	// map of supported extensions
	ext map[string]string
	// supported auth mechanisms
	auth       []string
	localName  string // the name to use in HELO/EHLO
	didHello   bool   // whether we've said HELO/EHLO
	helloError error  // the error from the hello
}

This way it's not possible to start smtp with any other mail server not running on localhost.

@MBakhshi96 MBakhshi96 changed the title net/smtp: No way to use other host name than localhost with helo command in smtp net/smtp: No way to use other host name than "localhost" with helo command in smtp Aug 13, 2019
@AlexRouSg
Copy link
Contributor

https://golang.org/pkg/net/smtp/#Client.Hello

Hello sends a HELO or EHLO to the server as the given host name. Calling this method is only necessary if the client needs control over the host name used. The client will introduce itself as "localhost" automatically otherwise. If Hello is called, it must be called before any of the other methods.

func (c *Client) Hello(localName string) error {
        ...
	c.localName = localName
	return c.hello()
}

@golang golang locked and limited conversation to collaborators Aug 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants