feat: send mail
This commit is contained in:
35
main.go
35
main.go
@@ -1,12 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/issue"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/mailer"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/model"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/pdf"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/report"
|
||||
@@ -99,9 +99,38 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ducument, err := pdfs.HtmlToPdf(html)
|
||||
document, err := pdfs.HtmlToPdf(html)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
io.Copy(os.Stdout, ducument)
|
||||
mlr, err := mailer.New(mailer.Config{
|
||||
SMTP: mailer.SMTPConfig{
|
||||
Host: "mail.your-server.de",
|
||||
Port: "465",
|
||||
User: "test@schreifuchs.ch",
|
||||
Password: "xV27D1nj33dNz8B4",
|
||||
},
|
||||
From: "test@schreifuchs.ch",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = mlr.Send(mailer.Mail{
|
||||
TO: "kontakt@schreifuchs.ch",
|
||||
Subject: "test",
|
||||
Body: "Hallo",
|
||||
Attachments: []mailer.Attachment{
|
||||
{
|
||||
Name: "invoice.pdf",
|
||||
MimeType: "pdf",
|
||||
Content: document,
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Filter[T any](slice []T, ok func(T) bool) []T {
|
||||
|
||||
Reference in New Issue
Block a user