Files
rs_website/internal/mailer/mailer.go

19 lines
519 B
Go

// Package mailer sends email via the local SMTP relay (OpenSMTPD on localhost:25).
package mailer
import (
"fmt"
"net/smtp"
)
const from = "noreply@ridgwaysystems.org"
// Send delivers a plain-text email through the local MTA.
func Send(to, subject, body string) error {
msg := fmt.Sprintf(
"From: %s\r\nTo: %s\r\nSubject: %s\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n%s",
from, to, subject, body,
)
return smtp.SendMail("localhost:25", nil, from, []string{to}, []byte(msg))
}