diff options
Diffstat (limited to 'incoming.go')
-rw-r--r-- | incoming.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/incoming.go b/incoming.go index f915ac0..169bde5 100644 --- a/incoming.go +++ b/incoming.go @@ -1,12 +1,28 @@ package main -import "go.lindenii.runxiyu.org/lindenii-common/clog" +import ( + "go.lindenii.runxiyu.org/lindenii-common/clog" + "os" + "path" + "time" +) -func deliver_incoming(envelope_from string, envelope_recipients []string, data []byte) { +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 } |