blob: 35aa006c0593245cc520a9dfb8753fd545af0cbf (
plain) (
tree)
|
|
package main
import (
"os"
"time"
"go.lindenii.runxiyu.org/lindenii-common/clog"
"go.lindenii.runxiyu.org/lindenii-common/misc"
)
func deliver_incoming(envelope_from string, envelope_recipients []string, data []byte) error {
clog.Debug(
"incoming_mail",
"envelope_from", envelope_from,
"envelope_recipients", envelope_recipients,
"data", string(data),
)
t := time.Now()
fd, err := misc.Open_file_at(directories.inbox, envelope_from+" "+t.Format(time.RFC3339Nano)+".eml", os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600)
if err != nil {
// TODO: handle fs.ErrExist
return misc.Wrap_one_error(err_deliver_write, err)
}
_, err = fd.Write(data)
if err != nil {
return misc.Wrap_one_error(err_deliver_write, err)
}
return nil
}
|