mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[server] Optional SMTP authentication
When using a local relay server, not authentication is needed. To support this use-case authentication is only send to the server when an user and password are set in the configuration file.
This commit is contained in:
parent
a9c646ca77
commit
d25420c867
@ -47,6 +47,10 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
|
||||
smtpEmail := viper.GetString("smtp.email")
|
||||
|
||||
var emailMessage string
|
||||
var auth smtp.Auth = nil
|
||||
if smtpUsername != "" && smtpPassword != "" {
|
||||
auth = smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)
|
||||
}
|
||||
|
||||
// Construct 'emailAddresses' with comma-separated email addresses
|
||||
var emailAddresses string
|
||||
@ -94,7 +98,6 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
|
||||
|
||||
// Send the email to each recipient
|
||||
for _, toEmail := range toEmails {
|
||||
auth := smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)
|
||||
err := smtp.SendMail(smtpServer+":"+smtpPort, auth, fromEmail, []string{toEmail}, []byte(emailMessage))
|
||||
if err != nil {
|
||||
errMsg := err.Error()
|
||||
|
Loading…
x
Reference in New Issue
Block a user