Skip to content

llEmail

void llEmail(string Address, string Subject, string Text)

Sends email to Address with Subject and Message.

Sends an email to Address with Subject and Message.

Parameters
Address (string)
Subject (string)
Text (string)

The message is prefixed with information about the prim sending the email in the following format:

Object-Name: <prim>
Region: <simname> (<simpos.x>, <simpos.y>)
Local-Position: (<primpos.x>, <primpos.y>, <primpos.z>)
<message>

Example:

Object-Name: Object
Region: Gibson (254976, 256000)
Local-Position: (117, 129, 50)
The real message starts here.
string emailAddress = "somebody@example.com";
string emailHeader = "Someone touched me!";
default
{
touch_start(integer num_detected)
{
// llSay(PUBLIC_CHANNEL, "Sending eMail report now, this will take ~20 seconds.");
key id = llDetectedKey(0);
string name = llDetectedName(0);
llEmail(emailAddress, emailHeader,
"I was touched by: '" + name + "' (" + (string)id + ").");
// llSay(PUBLIC_CHANNEL, "Email has been sent.");
}
}

In LSL you can send email with llEmail and receive it with the email event. When receiving a message sent with llEmail, it helps to separate the message from the prefixed header. The header and original message body are separated by "\n\n":

integer divide = llSubStringIndex(message, "\n\n");
string header = llDeleteSubString(message, divide, -1);
message = llDeleteSubString(message, 0, divide + 1);

To get individual header items:

list lines = llParseStringKeepNulls(header, ["\n"], []);
string objname_line = llList2String(lines, 0);
string region_line = llList2String(lines, 1);
string localpos_line = llList2String(lines, 2);

To extract a pure region name:

string region_name = llStringTrim(
(string)llDeleteSubList(
llParseStringKeepNulls(
llDeleteSubString(region_line, 0, 12),
[],
["("]
), -2, -1), STRING_TRIM);

This example demonstrates using email to check with a central server for object updates:

Client object:

string version = "1";
string type = "lolcube";
default
{
on_rez(integer start_param)
{
llEmail("5a634b27-f032-283f-2df2-55ead7724b23@lsl.secondlife.com",
version,
(string)llGetOwner() + "," + type);
}
}

Server:

default
{
state_entry()
{
llSetTimerEvent(15.0);
}
timer()
{
llGetNextEmail("", "");
}
email(string time, string address, string version, string message, integer num_left)
{
if ((integer)version < 2)
{
list info = llCSV2List(llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1));
llGiveInventory(llList2Key(info, 0), llList2String(info, 1));
}
if (num_left)
llGetNextEmail("","");
}
}

Strip the email header when receiving from a prim:

email(string time, string address, string subj, string message, integer num_left)
{
if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
}

Get the region name and object position from the email header:

string region = llList2String(llParseString2List(message, ["Region: "," ("], []),1);
vector position = (vector) ("<" + llList2String(llParseString2List(message, ["Local-Position: (",")\n\n"], []),1) + ">");
  • If you’re sending to the object owner, consider using llTargetedEmail instead
  • There is a limit to the number of email messages an object can send in a given amount of time
  • There is a limit of 500 messages from a single agent’s objects in a one-hour period
  • The 4096-byte size limit includes the subject line and automatically added text. The practical maximum body size is approximately 3600 bytes
  • Email throttling is per-user when the destination is outside of Second Life. Messages within the same region are not throttled beyond the 20-second delay
  • Due to bug SVC-23 (present since 2005), objects may stop receiving emails completely until either the region is restarted or the object crosses a region boundary. Don’t rely on this function for reliable inter-region messaging
  • Due to bug BUG-229767, an object’s email queue can become suspended until the object crosses a region border. A workaround is to implement a delay of about 30 seconds before first trying to send email to a freshly rezzed script, as registering the email event handler can take time
  • Due to bug SVC-391, llEmail will silently fail when non-ASCII characters are present in the subject. Non-ASCII characters in the message body will be replaced by ?
  • Because of the long delay (20 seconds), llEmail is often called from a second script triggered by link_message
  • To send email to a prim within Second Life, its address is [key]@lsl.secondlife.com
    • If llGetKey returns a2e76fcd-9360-4f6d-a924-000000000003, then its email address is a2e76fcd-9360-4f6d-a924-000000000003@lsl.secondlife.com
    • Agents do not have fixed email addresses; use llInstantMessage or llOwnerSay instead (or llRegionSayTo if both are known to be in the same region)