aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/email
diff options
context:
space:
mode:
Diffstat (limited to 'src/email')
-rw-r--r--src/email/email.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/email/email.go b/src/email/email.go
index 33b30e0..a1f7f0b 100644
--- a/src/email/email.go
+++ b/src/email/email.go
@@ -6,6 +6,8 @@ import (
"crypto/tls"
"fmt"
"math/rand/v2"
+ "log"
+ "errors"
"net/smtp"
"strconv"
"time"
@@ -29,14 +31,20 @@ Message-ID: <%s>
%s`
-func ServerError(fault error) error {
+func Send(subject, body string) {
+ if err := send(subject, body); err != nil {
+ log.Print(err)
+ }
+}
+
+func send(subject, body string) error {
if Config.Disabled {
- return fault
+ return errors.New(body)
}
msgid := strconv.FormatInt(rand.Int64(), 10) + "@" + Config.Host
msg := fmt.Sprintf(emailTemplate, Config.FromAddr, Config.ToAddr,
- "Error Report", time.Now().Format(time.RFC1123Z), msgid, fault)
+ subject, time.Now().Format(time.RFC1123Z), msgid, body)
tlsConfig := &tls.Config{
InsecureSkipVerify: false,