changeblog/1608301892

Automatically save sent files in “Sent”

Fri, 18 Dec 20 15:31:32 CET

Since it is what many mail clients do it might be helpful for other people to have this. As for me, I like to have all my outgoing mails automatically saved in a Sent directory, so that's what I want to do.

There are multiple ways to do this. I want to present a very simple way without sending your mail to yourself or something like that.

Outgoing mail is processed via upas/send or /mail/box/$user/pipefrom, if that exists. We use this feature to build or own little filter script for outgoing mails.

The script itself is very simple. We just need a temporary place to store the mail message, then save it in the Sent directory and forward it to the normal send routines:

#!/bin/rc

rfork en
# see /sys/src/cmd/upas/filterkit/pipefrom.sample .
bind -c /mail/tmp /tmp
TMP=/mail/tmp/mine.$pid

cat > $TMP

/bin/upas/mbappend /mail/box/<yourusername>/Sent < $TMP
/bin/upas/send $* < $TMP

Of course you need to create the directory /mail/box//Sent and exchange with your $user and make this script executable.

The Sent directory needs read and write access for your own user, which should be fine with the defaults.

If you want unauthenticated users to send mails to that directory you need to make this directory world-writable.

With these adjustments you can send mails with acme/marshal and they are automatically saved in your Sent mailbox.