Skip to content

Inter‐object email with llEmail()

lickx edited this page Dec 19, 2023 · 27 revisions

Inter-object email with llEmail() can be the foundation of more advanced LSL projects. Think of networked-vendors, inter-sim teleportation networks etc.

An object's email address is always in the form [email protected]

  • The uuid in the address is exactly what llGetKey() returns in an LSL script residing in an object/linkset.
  • Unlike URLs returned by llRequestURL(), a rezzed object's uuid/key never changes and is static; unless the object is re-rezzed, re-linked[?] or loaded from an OAR!
  • The server part of the address can be overridden from the default by changing the internal_object_host setting in OpenSim.ini

When an object emails another object, the mail doesn't use or need SMTP.

  • If the destination object exists on the sending objects' region, IMAP is bypassed by directly placing the mail in the region's mail queue, from where the destination object will retrieve it with llGetNextEmail().
  • If the destination exists on another region, the email will be put in the IMAP inbox; and automatically retrieved from IMAP when the destination object calls llGetNextEmail().

To enable object emailing inter-sim, an IMAP server will need to be setup. SMTP is not required.

apt-get install courier-imap

By default it listens on ipv6, not ipv4. We can fix that:

sudo vim /etc/courier/imapd

Change ADDRESS=0 to ADDRESS=0.0.0.0

You should block port 143 and 993 on your firewall, only opening it to localhost and optionally to any other simservers you own.

Using Courier without TLS (port 143)

Run without TLS only if you limit access (firewall) to localhost or your own private subnet. To disable the SSL version of Courier:

sudo service courier-imap-ssl stop
sudo systemctl disable courier-imap-ssl

Using Courier with TLS (port 993)

For Let's Encrypt support, see https://github.com/nicolas-dutertry/letsimap.

To disable the non-TLS version of courier:

sudo service courier-imap stop
sudo systemctl disable courier-imap

Making a user with a Maildir

You'll probably want a dedicated (linux) user account just for lsl mail. This user will also need a Maildir folder:

sudo adduser lslmail
(follow instructions)

su lslmail
maildirmake.courier ~/Maildir
or
maildirmake ~/Maildir
exit

Set up Mutt for reading/debugging email

It is useful to have a mailclient to inspect any messages objects send, at least while setting up the mailsystem. Alpine doesn't work well with Maildir, but Mutt does:

sudo apt-get install mutt

Then, create the file /etc/Muttrc.d/maildir.rc with the following contents:

set mbox_type=Maildir

set spoolfile="~/Maildir/"
set folder="~/Maildir/"
set mask="!^\\.[^.]"
set record="+.Sent"
set postponed="+.Drafts"

mailboxes ! + `\
for file in ~/Maildir/.*; do \
  box=$(basename "$file"); \
  if [ ! "$box" = '.' -a ! "$box" = '..' -a ! "$box" = '.customflags' \
      -a ! "$box" = '.subscriptions' ]; then \
    echo -n "\"+$box\" "; \
  fi; \
done`

macro index c "<change-folder>?<toggle-mailboxes>" "open a different folder"
macro pager c "<change-folder>?<toggle-mailboxes>" "open a different folder"

(taken from https://wiki.debian.org/Mutt)

Now you can run mutt to use the inbox

OpenSim.ini example

Assumes a non-TLS Courier on localhost, with no SMTP server (outbound email disabled):

[Startup]
emailmodule = DefaultEmailModule

[EMail]
enabled = true
enableEmailToExternalObjects = true
enableEmailToSMTP = false

IMAP_SERVER_TLS = false
IMAP_SERVER_HOSTNAME = 127.0.0.1
IMAP_SERVER_PORT = 143
IMAP_SERVER_LOGIN = lslmail
IMAP_SERVER_PASSWORD = yourpassword

Receiving mail from outside (and other grids' objects)

This can be realized by running a SMTP service such as postfix, which would put all incoming mail (catchall) to [email protected] (internal_object_host would then be defined as lsl.yourgrid.com) in the maildir that opensim uses (for example '/home/lslmail/Maildir').

Running a SMTP service is an advanced topic and should not be taken lightly, a misconfigured or insecure service can mean you land on several blacklists. If in doubt, don't do it and keep mail grid-local with IMAP.

Clone this wiki locally