3 changed files with 40 additions and 0 deletions
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"net/smtp" |
||||
"os" |
||||
) |
||||
|
||||
func email(id, text string) error { |
||||
smtpServer := os.Getenv("SMTP_SERVER") |
||||
fmt.Println("DEBUG", smtpServer) |
||||
auth := smtp.PlainAuth("", os.Getenv("SMTP_USER"), os.Getenv("SMTP_PASSWORD"), smtpServer) |
||||
to := []string{os.Getenv("NOTEHUB_ADMIN_EMAIL")} |
||||
msg := []byte("Subject: note reported\r\n\r\n" + |
||||
fmt.Sprintf("Note https://notehub.org/%s was reported: %q\r\n", id, text)) |
||||
return smtp.SendMail(smtpServer+":587", auth, to[0], to, msg) |
||||
} |
||||
Loading…
Reference in new issue