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

Unencrypted connection #113

Open
vladoohr opened this issue Mar 29, 2018 · 6 comments
Open

Unencrypted connection #113

vladoohr opened this issue Mar 29, 2018 · 6 comments

Comments

@vladoohr
Copy link

vladoohr commented Mar 29, 2018

Hello,

I am getting the followinfg error: unencrypted connection.
I am using MailHog as SMTP server.

Here is the code snipped:

func Send(mailInfo *Info, cfg *config.Config, template string) error {
d := gomail.NewDialer(cfg.Mail["host"], port, cfg.Mail["user"], cfg.Mail["password"])

d.TLSConfig = &tls.Config{InsecureSkipVerify: true}

err = d.DialAndSend(message)

return err

}

How I can use unencrypted connection with this library?

Thanks in advance.

@webluoye
Copy link

use go 1.9 or support ssl mail server

@pedromorgan
Copy link

See #108

@wickerplane
Copy link

wickerplane commented Feb 15, 2019

TL;DR: try setting your username (third argument ingomail.NewDialer) to an empty string

This seems to be a built in yet undocumented workaround that allows you to bypass these two if blocks from Dial() in gomail/smtp.go:

if d.Auth == nil && d.Username != "" {
		if ok, auths := c.Extension("AUTH"); ok {
			if strings.Contains(auths, "CRAM-MD5") {
				d.Auth = smtp.CRAMMD5Auth(d.Username, d.Password)
			} else if strings.Contains(auths, "LOGIN") &&
				!strings.Contains(auths, "PLAIN") {
				d.Auth = &loginAuth{
					username: d.Username,
					password: d.Password,
					host:     d.Host,
				}
			} else {
				d.Auth = smtp.PlainAuth("", d.Username, d.Password, d.Host)
			}
		}
	}

	if d.Auth != nil {
		if err = c.Auth(d.Auth); err != nil {
			c.Close()
			return nil, err
		}
	}

@weiye301
Copy link

Did you finally solve it and how to do it?

@gyqsophila
Copy link

@wickerplane but get another error : client is not auth to send anoymous mail FROM, have any idea ?

@pedromorgan
Copy link

see #182 ;-((

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

6 participants