Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

fixed bug.

Jackb7d372623919
diff --git a/core/internal/service/mail_service/sending.go b/core/internal/service/mail_service/sending.go
index a01cd2b6..10bb574a 100644
--- a/core/internal/service/mail_service/sending.go
+++ b/core/internal/service/mail_service/sending.go
@@ -97,6 +97,21 @@ type EmailSender struct {
connected bool // connection status
}
+type customAuth struct {
+ Username, Password string
+}
+
+func (a *customAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
+ return "PLAIN", []byte("\x00" + a.Username + "\x00" + a.Password), nil
+}
+
+func (a *customAuth) Next(fromServer []byte, more bool) ([]byte, error) {
+ if more {
+ return nil, errors.New("unexpected server response")
+ }
+ return nil, nil
+}
+
func NewEmailSender() *EmailSender {
e := &EmailSender{
Host: "localhost",
@@ -210,13 +225,17 @@ func (e *EmailSender) connectPlain() error {
}
}
- if e.Host != "postfix" && e.Port != "25" {
- auth := smtp.PlainAuth("", e.Email, e.Password, e.Host)
+ var auth smtp.Auth
- if err = client.Auth(auth); err != nil {
- client.Close()
- return fmt.Errorf("SMTP auth: %w", err)
- }
+ if e.Port == "25" {
+ auth = &customAuth{e.Email, e.Password}
+ } else {
+ auth = smtp.PlainAuth("", e.Email, e.Password, e.Host)
+ }
+
+ if err = client.Auth(auth); err != nil {
+ client.Close()
+ return fmt.Errorf("SMTP auth: %w", err)
}
e.client = client