-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E-posta ile bildirim özelliği, hata ve hata harici mesajların farklı …
…Mattermost kanallarına ve e-posta adreslerine bildirilmesi özelliği
- Loading branch information
Showing
6 changed files
with
133 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,26 @@ elasticsearch: | |
expireAfter: 30 | ||
minCount: 5 | ||
maxCount: 50 | ||
mattermost: | ||
channelId: k7z8p13hmpfgpgfya6118g153e | ||
apiToken: fj11m54hqf86jfaey5yu7eye1a | ||
url: https://chat.vkk.io | ||
notify: | ||
email: | ||
enabled: true | ||
info: | ||
smtpHost: smtp.gmail.com | ||
smtpPort: 587 | ||
from: [email protected] | ||
password: 123456 | ||
to: [email protected] | ||
error: | ||
smtpHost: smtp.gmail.com | ||
smtpPort: 587 | ||
from: [email protected] | ||
password: 123456 | ||
to: [email protected] | ||
mattermost: | ||
enabled: true | ||
info: | ||
channelId: channel id | ||
apiToken: api token | ||
error: | ||
channelId: channel id | ||
apiToken: api token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package notify | ||
|
||
import ( | ||
"es-backup/config" | ||
"net/smtp" | ||
"strconv" | ||
) | ||
|
||
func Email(params *config.Params, subject string, message string, isError bool) { | ||
if !params.Notify.Email.Enabled { | ||
return | ||
} | ||
|
||
var smtpHost, from, password, to string | ||
var smtpPort int | ||
|
||
if isError { | ||
smtpHost = params.Notify.Email.Error.SmtpHost | ||
smtpPort = params.Notify.Email.Error.SmtpPort | ||
from = params.Notify.Email.Error.From | ||
password = params.Notify.Email.Error.Password | ||
to = params.Notify.Email.Error.To | ||
} else { | ||
smtpHost = params.Notify.Email.Info.SmtpHost | ||
smtpPort = params.Notify.Email.Info.SmtpPort | ||
from = params.Notify.Email.Info.From | ||
password = params.Notify.Email.Info.Password | ||
to = params.Notify.Email.Info.To | ||
} | ||
|
||
auth := smtp.PlainAuth("", from, password, smtpHost) | ||
|
||
msg := []byte("From: " + from + "\r\n" + | ||
"To: " + to + "\r\n" + | ||
"Subject: [" + params.Hostname + "] " + subject + "\r\n\r\n" + | ||
message + "\r\n") | ||
|
||
_ = smtp.SendMail(smtpHost+":"+strconv.Itoa(smtpPort), auth, from, []string{to}, msg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters