forked from tildetown/town
19 lines
364 B
Go
19 lines
364 B
Go
package email
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
func SendLocalEmail(username, subject, body string) error {
|
|
cmd := exec.Command("/usr/sbin/sendmail", username)
|
|
cmd.Stdin = bytes.NewBufferString(fmt.Sprintf("Subject: %s\n\n%s", subject, body))
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
return fmt.Errorf("failed to send local email: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|