2022-03-05 16:27:09 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"github.com/wneessen/go-mail"
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-03-07 18:14:38 +01:00
|
|
|
th := os.Getenv("TEST_HOST")
|
2022-03-09 13:20:01 +01:00
|
|
|
if th == "" {
|
|
|
|
fmt.Printf("$TEST_HOST env variable cannot be empty\n")
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2022-03-10 10:53:38 +01:00
|
|
|
|
|
|
|
tu := os.Getenv("TEST_USER")
|
|
|
|
tp := os.Getenv("TEST_PASS")
|
|
|
|
c, err := mail.NewClient(th, mail.WithTimeout(time.Millisecond*500), mail.WithTLSPolicy(mail.TLSMandatory),
|
|
|
|
mail.WithSMTPAuth(mail.SMTPAuthDigestMD5), mail.WithUsername(tu), mail.WithPassword(tp))
|
2022-03-05 16:27:09 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("failed to create new client: %s\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2022-03-09 13:20:01 +01:00
|
|
|
//c.SetTLSPolicy(mail.TLSMandatory)
|
2022-03-05 16:27:09 +01:00
|
|
|
|
|
|
|
ctx, cfn := context.WithCancel(context.Background())
|
|
|
|
defer cfn()
|
|
|
|
|
|
|
|
if err := c.DialWithContext(ctx); err != nil {
|
|
|
|
fmt.Printf("failed to dial: %s\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2022-03-09 16:52:23 +01:00
|
|
|
|
|
|
|
m := mail.NewMsg()
|
|
|
|
m.From("wn@neessen.net")
|
|
|
|
m.To("test@test.de", "foo@bar.de", "blubb@blah.com")
|
|
|
|
m.Cc("cc@test.de", "cc@bar.de", "cc@blah.com")
|
|
|
|
m.SetMessageID()
|
|
|
|
m.SetBulk()
|
|
|
|
m.Header()
|
|
|
|
|
2022-03-05 16:27:09 +01:00
|
|
|
}
|