switch to another email lib to support more AUTH types

This commit is contained in:
Christoph Haas
2021-04-29 16:45:28 +02:00
parent 7b1f59d86a
commit 19e6fa2a1a
5 changed files with 80 additions and 53 deletions

View File

@@ -114,6 +114,7 @@ func NewConfig() *Config {
cfg.Email.Host = "127.0.0.1"
cfg.Email.Port = 25
cfg.Email.Encryption = common.MailEncryptionNone
cfg.Email.AuthType = common.MailAuthPlain
// Load config from file and environment
cfgFile, ok := os.LookupEnv("CONFIG_FILE")

View File

@@ -265,6 +265,7 @@ func (s *Server) GetPeerConfigMail(c *gin.Context) {
return
}
// Apply mail template
qrcodeFileName := "wireguard-qrcode.png"
var tplBuff bytes.Buffer
if err := s.mailTpl.Execute(&tplBuff, struct {
Peer wireguard.Peer
@@ -274,7 +275,7 @@ func (s *Server) GetPeerConfigMail(c *gin.Context) {
}{
Peer: peer,
User: user,
QrcodePngName: "wireguard-config.png",
QrcodePngName: qrcodeFileName,
PortalUrl: s.config.Core.ExternalUrl,
}); err != nil {
s.GetHandleError(c, http.StatusInternalServerError, "Template error", err.Error())
@@ -289,7 +290,13 @@ func (s *Server) GetPeerConfigMail(c *gin.Context) {
Data: bytes.NewReader(cfg),
},
{
Name: "wireguard-config.png",
Name: qrcodeFileName,
ContentType: "image/png",
Data: bytes.NewReader(png),
Embedded: true,
},
{
Name: qrcodeFileName,
ContentType: "image/png",
Data: bytes.NewReader(png),
},