Can send mail through a smtp relay
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fa494910cf
commit
b014c3fb3c
3 changed files with 57 additions and 24 deletions
24
main.go
24
main.go
|
|
@ -18,9 +18,10 @@ import (
|
|||
)
|
||||
|
||||
var myLDAP = LDAP{
|
||||
Host: "localhost",
|
||||
Port: 389,
|
||||
BaseDN: "dc=example,dc=com",
|
||||
Host: "localhost",
|
||||
Port: 389,
|
||||
BaseDN: "dc=example,dc=com",
|
||||
MailPort: 587,
|
||||
}
|
||||
|
||||
type ResponseWriterPrefix struct {
|
||||
|
|
@ -125,6 +126,23 @@ func main() {
|
|||
myLDAP.ServicePassword = val
|
||||
}
|
||||
|
||||
if val, ok := os.LookupEnv("SMTP_HOST"); ok {
|
||||
myLDAP.MailHost = val
|
||||
}
|
||||
if val, ok := os.LookupEnv("SMTP_PORT"); ok {
|
||||
if port, err := strconv.Atoi(val); err == nil {
|
||||
myLDAP.MailPort = port
|
||||
} else {
|
||||
log.Println("Invalid value for SMTP_PORT:", val)
|
||||
}
|
||||
}
|
||||
if val, ok := os.LookupEnv("SMTP_USER"); ok {
|
||||
myLDAP.MailUser = val
|
||||
}
|
||||
if val, ok := os.LookupEnv("SMTP_PASSWORD"); ok {
|
||||
myLDAP.MailPassword = val
|
||||
}
|
||||
|
||||
// Prepare graceful shutdown
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue