blob: 169bde549f7246fd2c2cb5024b3fb97fa09a051d (
plain) (
tree)
|
|
package main
import (
"go.lindenii.runxiyu.org/lindenii-common/clog"
"os"
"path"
"time"
)
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, 0660) // 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
}
|