Compare commits
1 commit
d77b1a8d43
...
a077e60cc5
Author | SHA1 | Date | |
---|---|---|---|
a077e60cc5 |
1 changed files with 9 additions and 14 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"math/big"
|
||||
"github.com/wneessen/go-mail"
|
||||
|
@ -136,8 +135,7 @@ func (r *RequestRepo) sendConfirmationMail(request models.Request) error {
|
|||
var data = struct {
|
||||
Config config.Config
|
||||
Request models.Request
|
||||
MessageId template.HTML
|
||||
}{r.config, request, template.HTML("<" + randomString(15) + "@" + r.config.Server.Domain + ">")}
|
||||
}{r.config, request }
|
||||
err := templating.WriteTemplate(&messageText, "confirmationMail", data)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error parsing confirmation Mail: %w", err)
|
||||
|
@ -165,8 +163,14 @@ func (r *RequestRepo) sendConfirmationMail(request models.Request) error {
|
|||
message.Subject("Sprechstunde löschen")
|
||||
}
|
||||
message.SetBodyString(mail.TypeTextPlain, messageText.String())
|
||||
client, err := mail.NewClient(r.config.Mailer.SmtpHost, mail.WithPort(r.config.Mailer.SmtpPort))/*, mail.WithSMTPAuth(mail.SMTPAuthPlain),
|
||||
mail.WithUsername(r.config.Mailer.SmtpIdentity), mail.WithPassword(r.config.Mailer.SmtpPassword))*/
|
||||
|
||||
var options []mail.Option
|
||||
if r.config.Mailer.SmtpUseAuth {
|
||||
options = append(options, mail.WithSMTPAuth(mail.SMTPAuthPlain))
|
||||
options = append(options, mail.WithUsername(r.config.Mailer.SmtpIdentity))
|
||||
options = append(options, mail.WithPassword(r.config.Mailer.SmtpPassword))
|
||||
}
|
||||
client, err := mail.NewClient(r.config.Mailer.SmtpHost, mail.WithPort(r.config.Mailer.SmtpPort))
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
return err;
|
||||
|
@ -175,15 +179,6 @@ func (r *RequestRepo) sendConfirmationMail(request models.Request) error {
|
|||
log.Println(err.Error())
|
||||
return err;
|
||||
}
|
||||
/* var auth smtp.Auth
|
||||
if r.config.Mailer.SmtpUseAuth {
|
||||
auth = smtp.PlainAuth(r.config.Mailer.SmtpIdentity, r.config.Mailer.FromAddress, r.config.Mailer.SmtpPassword, r.config.Mailer.SmtpHost)
|
||||
}
|
||||
err = smtp.SendMail(fmt.Sprintf("%s:%d", r.config.Mailer.SmtpHost, r.config.Mailer.SmtpPort), auth, string(r.config.Mailer.FromName), to, message.Bytes())
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error sending mail by smtp: %w", err)
|
||||
log.Println(err.Error())
|
||||
}*/
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue