Sends an email to address with subject and message.
void llEmail( string address, string subject, string message );
Forced delay: 20.0 seconds. Energy: 10.0.
The entire message (including the address, subject and other miscellaneous fields) can't be longer than 4096 bytes combined.
The message is prefixed with information about the prim sending the email.
| Template | Example |
|---|---|
| |
"there has long been a throttle that makes a single script sleep for 20 seconds after sending an email. The new throttle is per user... some were using many, many different scripts to send spam. (the new throttle applies) when the destination is outside of Second Life. I know that messages within the same region were not throttled (beyond the 20-second delay), and I *believe* that messages between different sims were not throttled (between the 20-second delay)."
"?".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.");
}
}
email(string time, string address, string subj, string message, integer num_left)
{
if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com") //trim the header
message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
}
Get the region name and object position of the object that sent the email:
string region = llList2String(llParseString2List(message, ["Region: "," ("], []),1);
vector position = (vector) ("<" + llList2String(llParseString2List(message, ["Local-Position: (",")\n\n"], []),1) + ">");
[key]@lsl.secondlife.com
a2e76fcd-9360-4f6d-a924-000000000003", then its email address is "a2e76fcd-9360-4f6d-a924-000000000003@lsl.secondlife.com".In LSL you can both send email with llEmail and receive it with the email event.
The email event is triggered with five pieces of information:
| string | time | When the message was sent, in the (string)llGetUnixTime format |
| string | address | Who sent the message |
| string | subject | Subject of the message |
| string | message | Body of the message |
| integer | num_left | The number of emails left in the email queue |
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 just one of the header items, do this:
list lines = llParseStringKeepNulls(header, ["\n"], []);
string objname_line = llList2String(lines, 0);
string region_line = llList2String(lines, 1);
string localpos_line = llList2String(lines, 2);
To get a pure region name, do this:
string region_name = llStringTrim(
(string)llDeleteSubList(
llParseStringKeepNulls(
llDeleteSubString(region_line, 0, 12),
[],
["("]
), -2, -1), STRING_TRIM);
This application uses email to have objects check with a central server to see if the owner has the latest version. In the objects:
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);
}
}
The 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("","");
}
}