shithub: sirjofri_de

ref: 5d3e0b627b5d4f220ce20949230e70f1ea5ac378
dir: /changeblog/1608301892.txt/

View raw version
Automatically save sent files in “Sent”

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:

[[[ms
.P1
#!/bin/rc
.br
rfork en
# see /sys/src/cmd/upas/filterkit/pipefrom.sample .
bind -c /mail/tmp /tmp
TMP=/mail/tmp/mine.$pid
.br
cat > $TMP
.br
/bin/upas/mbappend /mail/box/<yourusername>/Sent < $TMP
/bin/upas/send $* < $TMP
.P2
]]]
[[[ebook
<code><pre>
#!/bin/rc

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

cat &gt; $TMP

/bin/upas/mbappend /mail/box/&lt;yourusername&gt;/Sent &lt; $TMP
/bin/upas/send $* &lt; $TMP
</pre></code>
]]]

Of course you need to create the directory ‥‥‥/mail/box/<yourusername>/Sent‥‥‥ and exchange ‥‥‥<yourusername>‥‥‥
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.