[GH-ISSUE #4] SMTP doesn't support AUTH #5

Closed
opened 2026-03-15 12:01:38 +03:00 by kerem · 5 comments
Owner

Originally created by @kaptinlin on GitHub (Aug 5, 2022).
Original GitHub issue: https://github.com/axllent/mailpit/issues/4

Hi, I got a error when send via smtp

smtp: server doesn't support AUTH
Originally created by @kaptinlin on GitHub (Aug 5, 2022). Original GitHub issue: https://github.com/axllent/mailpit/issues/4 Hi, I got a error when send via smtp ``` smtp: server doesn't support AUTH ```
kerem closed this issue 2026-03-15 12:01:43 +03:00
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

The SMTP server doesn't currently support authentication, it's just open/non-encrypted. Can you please tell me your use-case and requirements?

<!-- gh-comment-id:1206584980 --> @axllent commented on GitHub (Aug 5, 2022): The SMTP server doesn't currently support authentication, it's just open/non-encrypted. Can you please tell me your use-case and requirements?
Author
Owner

@kaptinlin commented on GitHub (Aug 5, 2022):

Some lib check username and password, and using smtp.PlainAuth send emails. If there is no username and password, it dont work.

Another node.js based app maildev can work with it. But if mailpit can support it that would be better.

maildev:
    image: maildev/maildev:latest
    environment:
      MAILDEV_INCOMING_USER: "hello@example.com"
      MAILDEV_INCOMING_PASS: "password"
    ports:
      - "1080:1080"
      - "1025:1025"
<!-- gh-comment-id:1206675655 --> @kaptinlin commented on GitHub (Aug 5, 2022): Some [lib check username and password](https://github.com/ainsleyclark/go-mail/blob/main/drivers/smtp.go#L50), and using `smtp.PlainAuth` send emails. If there is no username and password, it dont work. Another node.js based app maildev can work with it. But if mailpit can support it that would be better. ``` maildev: image: maildev/maildev:latest environment: MAILDEV_INCOMING_USER: "hello@example.com" MAILDEV_INCOMING_PASS: "password" ports: - "1080:1080" - "1025:1025" ```
Author
Owner

@axllent commented on GitHub (Aug 5, 2022):

@KaptinLin I have started working on this feature.

I think you are going to hit some major issues with this go-mail library though as it appears to have very limited SMTP options. To use SMTP authentication (with go-mail ~ or any compliant SMTP client) TLS must be enabled on the SMTP server (this is standard). That's OK (I am adding this option), however go-mail also requires that the SSL certificate be valid, officially signed (no self-signed certificates), and the certificate AltName (not the FQDN / Fully Qualified Domain Name) must match the SMTP mail.Config.URL - else go-mail just refuses to send (errors).

So yes, support for this is coming soon, however I don't think you will get very far with go-mail unless you are using a FQDN with a valid, signed SSL certificate (not self-signed) - such as a public server with a valid Let's Encrypt certificate.

In my local test (Mailpit support for SMTP TLS / auth will be released in the next few hours) I couldn't find any way of telling go-mail to skip certificate verification. What I tried was:

c := http.Client{
	Transport: &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	},
}
cfg := mail.Config{
	URL:         "localhost",
	FromAddress: "test@example.com",
	FromName:    "Gopher",
	Password:    "test",
	Port:        1025,
	Client:      &c,
}

~ but this just did not work for go-mail no matter what I tried. I was however able to get it working locally with jordan-wright/email which dos allow you to skip SSL verification. I am just mentioning this as I think you may get stuck with go-mail (unless you find a work-around that I didn't find).....

<!-- gh-comment-id:1207073410 --> @axllent commented on GitHub (Aug 5, 2022): @KaptinLin I have started working on this feature. I think you are going to hit some major issues with this go-mail library though as it appears to have very limited SMTP options. To use SMTP authentication (with go-mail ~ or any compliant SMTP client) TLS **must** be enabled on the SMTP server (this is standard). That's OK (I am adding this option), however go-mail also **requires** that the SSL certificate be valid, **officially signed** (no self-signed certificates), and the certificate _AltName_ (not the FQDN / Fully Qualified Domain Name) **must match** the SMTP `mail.Config.URL` - else go-mail just refuses to send (errors). So yes, support for this is coming soon, however I don't think you will get very far with go-mail unless you are using a FQDN with a valid, signed SSL certificate (not self-signed) - such as a public server with a valid Let's Encrypt certificate. In my local test (Mailpit support for SMTP TLS / auth will be released in the next few hours) I couldn't find any way of telling go-mail to skip certificate verification. What I tried was: ``` c := http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, }, } cfg := mail.Config{ URL: "localhost", FromAddress: "test@example.com", FromName: "Gopher", Password: "test", Port: 1025, Client: &c, } ``` ~ but this just did not work for go-mail no matter what I tried. I was however able to get it working locally with [jordan-wright/email](github.com/jordan-wright/email) which dos allow you to skip SSL verification. I am just mentioning this as I think you may get stuck with go-mail (unless you find a work-around that I didn't find).....
Author
Owner

@axllent commented on GitHub (Aug 6, 2022):

@KaptinLin I have added SMTP STARTTLS & authentication to the 0.1.0 release. As I mentioned previously, unless you are using a resolvable and public DNS with an ifficially signed certificate, I don't think the go-mail library will work. If you do however manage to find a way to get it to InsecureSkipVerify then please let me know.

<!-- gh-comment-id:1207171620 --> @axllent commented on GitHub (Aug 6, 2022): @KaptinLin I have added SMTP STARTTLS & authentication to the 0.1.0 release. As I mentioned previously, unless you are using a resolvable and public DNS with an ifficially signed certificate, I don't think the go-mail library will work. If you do however manage to find a way to get it to `InsecureSkipVerify` then please let me know.
Author
Owner

@kaptinlin commented on GitHub (Aug 6, 2022):

Awesome! It seems good.

<!-- gh-comment-id:1207229180 --> @kaptinlin commented on GitHub (Aug 6, 2022): Awesome! It seems good.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#5
No description provided.