playground:test
Differences
This shows you the differences between two versions of the page.
playground:test [2021/04/18 14:28] – created gall0ws | playground:test [2021/04/18 14:47] (current) – typos and minor stuff gall0ws | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Receiving and sending emails with 9front ====== | ||
+ | |||
+ | In this tutorial we're going to show how to configure on 9front IMAP | ||
+ | and SMTP access for your SDF mailbox. | ||
+ | |||
+ | Note that for using SMTP on SDF you have to be a META, VHOST, VPM or | ||
+ | DIALUP member. | ||
+ | |||
+ | In the course of this article we will use some uppercasi variables | ||
+ | you've got to replace appopriately for your use case: | ||
+ | |||
+ | SDF_USER - username to login to the SDF shell | ||
+ | SDF_PASSWORD - password to login to the SDF shell, it will be used for IMAP auth as well | ||
+ | SMTP_SECRET - you may need to set this one up, it will be used for SMTP auth | ||
+ | |||
+ | ===== 1. Receiving ===== | ||
+ | |||
+ | |||
+ | ==== 1.1 Add your password to factotum(4) ==== | ||
+ | |||
+ | |||
+ | In order to access your mailbox, we store the credentials in factotum | ||
+ | adding the appopriate key: | ||
+ | |||
+ | % echo 'key proto=pass server=mx.sdf.org service=imap user=SDF_USER !password=SDF_PASSWORD' | ||
+ | > / | ||
+ | |||
+ | ==== 1.2 upasfs(4) ==== | ||
+ | |||
+ | |||
+ | '' | ||
+ | as a filesystem. | ||
+ | with: | ||
+ | |||
+ | % upas/fs -f '/ | ||
+ | |||
+ | You'll find the mailbox mounted under / | ||
+ | |||
+ | === 1.2.1 Non-default mailbox === | ||
+ | |||
+ | |||
+ | If you're already using '' | ||
+ | will most probably fail as you already have another mailbox named '' | ||
+ | Of course you can have many different mailboxes, to create a separate | ||
+ | one for SDF: | ||
+ | |||
+ | % echo open / | ||
+ | |||
+ | In this scenario the SDF mailbox will be mounted under ''/ | ||
+ | |||
+ | See '' | ||
+ | |||
+ | For the rest of this article we're assuming that the mailbox is | ||
+ | mounted as the default one, and the programs we're going to use make | ||
+ | the same assumption, however such programs accept a flag or an | ||
+ | additional parameter to specify a different mailbox. | ||
+ | the appropriate manual pages for more details. | ||
+ | |||
+ | === 1.2.2 IMAP server certificate. === | ||
+ | |||
+ | |||
+ | The very first time you try to access mx.sdf.org with upas you'll get | ||
+ | an error: | ||
+ | |||
+ | upas/fs: opening / | ||
+ | |||
+ | That's because the X.509 certificate is unknown to your system; to | ||
+ | make it trusted for the mailer just add it to the file '' | ||
+ | ''/ | ||
+ | |||
+ | % echo 'x509 sha256=j1iBZLD5iPEcGYJopv9oMBHjZcZAzTsfAzj7bIXA2T4' | ||
+ | |||
+ | === 1.2.3 Namespaces considerations === | ||
+ | |||
+ | If you're running '' | ||
+ | out that a fresh new window won't inherith the previously opened mbox. | ||
+ | That's because it was mounted in a different process group and its | ||
+ | namespace is not fully shared with every other process. | ||
+ | |||
+ | To do that, you may want run '' | ||
+ | '' | ||
+ | |||
+ | Another way to share the mail box is launching '' | ||
+ | |||
+ | % upas/fs -s -f '/ | ||
+ | |||
+ | From '' | ||
+ | |||
+ | -s causes fs to put itself in /srv with a name of | ||
+ | the form / | ||
+ | |||
+ | That allows you to mount back your mailbox in a separate process group running: | ||
+ | |||
+ | % mount / | ||
+ | |||
+ | ==== 1.3 Read emails ==== | ||
+ | |||
+ | The mbox is exposed as a filesystem where each email is presented as a | ||
+ | directory, e.g.: | ||
+ | |||
+ | % lc / | ||
+ | bcc disposition from messageid rawunix subject | ||
+ | body ffrom header mimeheader references to | ||
+ | cc fileid info raw replyto type | ||
+ | date filename inreplyto rawbody sender unixdate | ||
+ | digest flags lines rawheader size unixheader | ||
+ | |||
+ | Every file in such directories contains the relative data about the email. | ||
+ | This is a great API, because it makes very easy to write your own mail | ||
+ | client. | ||
+ | We could also read the email directly from the shell with something | ||
+ | like: | ||
+ | |||
+ | % for (i in from subject body) echo $i: `{cat / | ||
+ | |||
+ | But that isn't really that great, is it? | ||
+ | |||
+ | === 1.3.1 nedmail(1) === | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | when '' | ||
+ | |||
+ | //TODO: expand.// | ||
+ | |||
+ | === 1.3.2 faces(1) === | ||
+ | |||
+ | With '' | ||
+ | |||
+ | % faces -i | ||
+ | |||
+ | {{: | ||
+ | |||
+ | It uses the '' | ||
+ | '' | ||
+ | can be displayed by another program. | ||
+ | |||
+ | === 1.3.3 acmemail(1) === | ||
+ | |||
+ | Mail allows you to manage your mailbox directly inside '' | ||
+ | |||
+ | All you have to do is launch acme: | ||
+ | |||
+ | % acme | ||
+ | |||
+ | And then run '' | ||
+ | By default it will open a new window ''/ | ||
+ | and read your mailbox. | ||
+ | |||
+ | Right-clicking on a message id will open the message in a new window. | ||
+ | |||
+ | '' | ||
+ | for instance the read status of a message. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | See '' | ||
+ | details. | ||
+ | |||
+ | ===== 2. Sending ===== | ||
+ | |||
+ | As mentioned in the intro, you need a META, VHOST, VPM or | ||
+ | DIALUP membership to send emails through SDF. | ||
+ | |||
+ | See https:// | ||
+ | |||
+ | ==== 2.1 SDF SMTP configuration from 9front ==== | ||
+ | |||
+ | To setup the SDF SMTP from 9front you can use '' | ||
+ | |||
+ | % vt | ||
+ | % ssh SDF_USER@tty.sdf.org | ||
+ | |||
+ | Then on the SDF shell: | ||
+ | |||
+ | sdf$ setdialup | ||
+ | SETDIALUP Version 3 | ||
+ | |||
+ | [p] Set your DIALUP and SMTP Auth password | ||
+ | [m] Toggle SDF_USER@tenex.org email address | ||
+ | [n] Set your connection type to NETWORK PPP (default) | ||
+ | [s] Set your connection type to SHELL | ||
+ | [t] Set your connection to TIP | ||
+ | [r] REMOVE your DIALUP Membership | ||
+ | [q] QUIT | ||
+ | |||
+ | Choice? | ||
+ | |||
+ | At this prompt you should choose '' | ||
+ | '' | ||
+ | |||
+ | ==== 2.2 rewrite(6) ==== | ||
+ | |||
+ | ''/ | ||
+ | destination to a command to properly send the email. | ||
+ | |||
+ | By default rewrite doesn' | ||
+ | just use the template provided by '' | ||
+ | |||
+ | % cat / | ||
+ | |||
+ | See '' | ||
+ | |||
+ | ==== 2.3 / | ||
+ | |||
+ | This script is used by ''/ | ||
+ | |||
+ | We can edit it in order to hardcode '' | ||
+ | |||
+ | #!/bin/rc | ||
+ | shift | ||
+ | sender=SDF_USER@sdf.org | ||
+ | shift | ||
+ | addr=tcp!mx.sdf.org!25 | ||
+ | shift | ||
+ | fd=`{/ | ||
+ | switch($fd){ | ||
+ | case *.* | ||
+ | ; | ||
+ | case * | ||
+ | fd=sdf.org | ||
+ | } | ||
+ | exec / | ||
+ | |||
+ | === 2.3.1 Avoid to overwrite defaults === | ||
+ | |||
+ | In a shared system changing ''/ | ||
+ | alternative way to do that is creating a '' | ||
+ | make there the changes we described, finally use '' | ||
+ | the global one just inside our namespace: | ||
+ | |||
+ | % bind -b $user/ | ||
+ | |||
+ | See '' | ||
+ | |||
+ | ==== 2.4 Add your SMTP secret to factotum ==== | ||
+ | |||
+ | Similarly at what we did in 1.1 for IMAP, we're adding our credentials | ||
+ | in factotum to access SDF SMTP server. | ||
+ | |||
+ | % echo 'key proto=cram server=mx.sdf.org user=SDF_USER.tenex.org@sdf.org !password=SMTP_SECRET' | ||
+ | > / | ||
+ | |||
+ | Note that the proto in this case is '' | ||
+ | mentionened in the SDF FAQ, is sligthly different than usual. | ||
+ | |||
+ | ==== 2.5 SMTP server certificate. ==== | ||
+ | |||
+ | As the SMTP server is mx.sdf.org, we can just copy the cert we | ||
+ | used for IMAP (see 1.2.2): | ||
+ | |||
+ | % cp / | ||
+ | |||
+ | ==== 2.6 Post email ==== | ||
+ | |||
+ | |||
+ | Now we're almost ready to send emails from 9front using SDF! | ||
+ | |||
+ | === 2.6.1 Correct From field === | ||
+ | |||
+ | |||
+ | With the setup described in this article you're going to send emails | ||
+ | with '' | ||
+ | (oh, hi!) or in general $user doesn' | ||
+ | to have the upasname env variable set to SDF_USER: | ||
+ | |||
+ | % upasname=SDF_USER | ||
+ | |||
+ | You may want to set this inside '' | ||
+ | error. | ||
+ | |||
+ | === 2.6.1 mail(1) === | ||
+ | |||
+ | |||
+ | The simplest way to send an email is: | ||
+ | |||
+ | % echo 'this is a test' | mail -s test gurdulu@sdf.org | ||
+ | |||
+ | when '' | ||
+ | |||
+ | === 2.6.2 acmemail(1) === | ||
+ | |||
+ | '' | ||
+ | send emails directly from '' | ||
+ | |||
+ | You can start composing a new email middle-clicking '' | ||
+ | window: a new window will be opened, fill the email in and finally middle-click Post to send it. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== 2.7 Troubleshooting ==== | ||
+ | |||
+ | % tail -f / | ||
+ | |||
+ | % tail -f / | ||