1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
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
}
|