diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-12 04:38:25 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-12 04:42:09 +0800 |
commit | 27cf6309af4536be615a34a647bbc54e6f8f43c6 (patch) | |
tree | 7563339698b24510f1024c4904f5a55ff7614c03 /incoming.go | |
parent | Update README (diff) | |
download | maild-27cf6309af4536be615a34a647bbc54e6f8f43c6.tar.gz maild-27cf6309af4536be615a34a647bbc54e6f8f43c6.tar.zst maild-27cf6309af4536be615a34a647bbc54e6f8f43c6.zip |
Add basic routing
Diffstat (limited to 'incoming.go')
-rw-r--r-- | incoming.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/incoming.go b/incoming.go index 35aa006..e672587 100644 --- a/incoming.go +++ b/incoming.go @@ -8,7 +8,7 @@ import ( "go.lindenii.runxiyu.org/lindenii-common/misc" ) -func deliver_incoming(envelope_from string, envelope_recipients []string, data []byte) error { +func deliver_incoming(envelope_from string, envelope_recipients []string, data []byte, dir_path string) error { clog.Debug( "incoming_mail", "envelope_from", envelope_from, @@ -16,7 +16,11 @@ func deliver_incoming(envelope_from string, envelope_recipients []string, data [ "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) + dir, err := misc.Open_directory_readonly(dir_path) + if err != nil { + return misc.Wrap_one_error(err_deliver_write, err) + } + fd, err := misc.Open_file_at(dir, 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) |