From 85adb885fe8ff4836156e1f95cc8f94a95aca4e9 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 20 Aug 2024 23:55:42 +0800 Subject: [PATCH] chore: tweak comments --- plugin/mail/login_auth.go | 2 +- plugin/mail/mail.go | 28 +++------------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/plugin/mail/login_auth.go b/plugin/mail/login_auth.go index 23a08e6..a052a1b 100644 --- a/plugin/mail/login_auth.go +++ b/plugin/mail/login_auth.go @@ -27,7 +27,7 @@ func (la *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { case "Password:": return []byte(la.password), nil default: - return nil, errors.New("Unknown fromServer") + return nil, errors.New("unknown fromServer") } } return nil, nil diff --git a/plugin/mail/mail.go b/plugin/mail/mail.go index d3d55e4..399b070 100644 --- a/plugin/mail/mail.go +++ b/plugin/mail/mail.go @@ -1,27 +1,5 @@ -// Package mail is a mail delivery plugin based on SMTP. package mail -// Usage: -// email := NewEmailMsg().SetFrom("yourselfhosted ").AddTo("Customer ").SetSubject("Test Email Subject").SetBody(` -// -// -// -// HTML Test -// -// -//

This is a mail delivery test.

-// -// -// `) -// fmt.Printf("email: %+v\n", email) -// client := NewSMTPClient("smtp.gmail.com", 587) -// client.SetAuthType(SMTPAuthTypePlain) -// client.SetAuthCredentials("from@yourselfhosted.com", "nqxxxxxxxxxxxxxx") -// client.SetEncryptionType(SMTPEncryptionTypeSTARTTLS) -// if err := client.SendMail(email); err != nil { -// t.Fatalf("SendMail failed: %v", err) -// } - import ( "crypto/tls" "fmt" @@ -80,7 +58,7 @@ func (e *Email) AddTo(to ...string) *Email { for _, toAddress := range to { parsedAddr, err := mail.ParseAddress(toAddress) if err != nil { - e.err = errors.Wrapf(err, "Invalid to address: %s", toAddress) + e.err = errors.Wrapf(err, "invalid to address: %s", toAddress) return e } buf = append(buf, parsedAddr) @@ -97,7 +75,7 @@ func (e *Email) SetSubject(subject string) *Email { return e } if e.subject != "" { - e.err = errors.New("Subject already set") + e.err = errors.New("subject already set") return e } e.subject = subject @@ -192,7 +170,7 @@ func (c *SMTPClient) SendMail(e *Email) error { case SMTPEncryptionTypeSTARTTLS: return e.e.SendWithStartTLS(fmt.Sprintf("%s:%d", c.host, c.port), c.getAuth(), &tls.Config{InsecureSkipVerify: true}) default: - return errors.Errorf("Unknown SMTP encryption type: %d", c.encryptionType) + return errors.Errorf("unknown SMTP encryption type: %d", c.encryptionType) } }