blob: e264262bb58a142fc8fe4454cadea6430e2e7a23 (
plain) (
tree)
|
|
package main
import (
"os"
"path"
"time"
"go.lindenii.runxiyu.org/lindenii-common/clog"
)
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 := os.OpenFile(path.Join(config.Inbox_path, envelope_from+" "+t.Format(time.RFC3339Nano)+".eml"), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o660) // TODO: vulnerability
if err != nil {
// TODO: handle fs.ErrExist
return err_deliver_write
}
_, err = fd.Write(data)
if err != nil {
return err_deliver_write
}
return nil
}
|