Difference between revisions of "Email"

From Second Life Wiki
Jump to navigation Jump to search
m
m (Replaced <source> with <syntaxhighlight>, added Haiku by the Poem Generator)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Issues/SVC-23}}{{LSL_Event
{{LSL_Event
|inject-2={{Issues/SVC-23}}{{Issues/SVC-391}}{{Issues/SVC-412}}{{Issues/SCR-499}}{{Issues/BUG-229767}}
|event_id=21|event_delay
|event_id=21|event_delay
|event=email
|event=email
Line 6: Line 7:
|p3_type=string|p3_name=subject|p3_desc
|p3_type=string|p3_name=subject|p3_desc
|p4_type=string|p4_name=message|p4_desc
|p4_type=string|p4_name=message|p4_desc
|p5_type=integer|p5_name=num_left|p5_desc=The number of emails left in the email queue
|p5_type=integer|p5_name=num_left|p5_desc=The number of emails remaining in the email queue.{{Footnote|The email being processed is not counted as it has already been popped from the queue.}}|p5_hover=The number of emails left in the email queue.
|event_desc=Triggered as a result of calling [[llGetNextEmail]] where there is a matching email in the email queue.
|event_desc=Triggered as a result of calling [[llGetNextEmail]] where there is a matching email in the email queue.
|event_footnote=The email queue is associated with the prim and any script in the prim can access it. <br/> The prim's email address is it's key with "@lsl.secondlife.com" appended, <code>[[llGetKey]]() + "@lsl.secondlife.com"</code>{{Footnote|1=Preview grid email address are constructed differently: <code style="font-size: 123%;">[[llGetKey]]() + "@lsl." + grid + ".lindenlab.com"</code>; for the main beta grid set grid to {{String|aditi}}.|2=Beta grid email address are constructed differently: llGetKey() + {{String|@lsl.}} + grid + {{String|.lindenlab.com}}; for the main beta grid set grid to {{String|aditi}}.}}.
|event_footnote=The email queue is associated with the prim and any script in the prim can access it. <br/> The prim's email address is its key with "@lsl.secondlife.com" appended, <code>[[llGetKey]]() + "@lsl.secondlife.com"</code>{{Footnote|1=Preview grid email address are constructed differently: <code style="font-size: 123%;">[[llGetKey]]() + "@lsl." + grid + ".lindenlab.com"</code>; for the main beta grid set grid to {{String|aditi}}.|2=Beta grid email address are constructed differently: llGetKey() + {{String|@lsl.}} + grid + {{String|.lindenlab.com}}; for the main beta grid set grid to {{String|aditi}}.}}.
|constants
|constants
|spec=The email event is triggered as a result of calling [[llGetNextEmail]] when there is an email that matches [[llGetNextEmail]]'s optional filters. The first email that matches the filters is removed from the email queue and it's data is used as the parameters for this event. If no email matches the filters but the queue is not empty this event is not triggered. Besides the effects of filtering, the email queue is {{HoverText|FIFO|First In First Out}}.
|spec=The email event is triggered as a result of calling [[llGetNextEmail]] when there is an email that matches [[llGetNextEmail]]'s optional filters. The first email that matches the filters is removed from the email queue and its data is used as the parameters for this event. If no email matches the filters but the queue is not empty this event is not triggered. Besides the effects of filtering, the email queue is {{HoverText|FIFO|First In First Out}}.
|caveats=
|caveats=
* The email queue is limited to 100 emails, any email after that is bounced.
* The email queue is limited to 100 emails, any email after that is bounced.
* The message field may have a maximum of 1000 characters. This count includes the header information ('''address''', '''subject''', etc).
* The message field may have a maximum of 1000 single-byte characters. This count includes the header information ('''address''', '''subject''', etc).
* [[llEmail|Emails sent from within SL]] will have their message body prefixed with a header detailing the originating prim. See [[llEmail]] for more details.
* [[llEmail|Emails sent from within SL]] will have their message body prefixed with a header detailing the originating prim. See [[llEmail]] for more details.
* Due to bug {{Jira|SVC-23}} (present since 2005), objects may stop receiving emails completely until either the region is restarted or the object crosses a region boundary (resetting the script doesn't help). Emails sent may eventually be received after a restart/region-cross. Hence, don't rely on this event for reliable inter-region messaging.  
* Due to bug {{Jira|SVC-23}} (present since 2005), objects may stop receiving emails completely until either the region is restarted or the object crosses a region boundary (resetting the script doesn't help).
* Due to bug {{JIRA|BUG-229767}}, an object's email queue can still become suspended until the object crosses a region border (neither a region restart nor a script reset helps). First analysis has revealed a potential workaround, by implementing a delay of about 30 seconds before first trying to send email to a freshly rezzed script - apparently registering the email(...) event handler can take quite some time, and emails arriving prior to said registry process is what gets the entire queue stuck. Official Linden response still pending.
 
|constants
|constants
|examples=<lsl>default
|examples=
<syntaxhighlight lang="lsl2">
default
{
{
     state_entry()
     state_entry()
Line 23: Line 28:
         llSetTimerEvent(5.0);
         llSetTimerEvent(5.0);
     }
     }
 
     timer()
     timer()
     {
     {
    //  get next email, don't filter by sender or subject
         llGetNextEmail("", "");
         llGetNextEmail("", "");
     }
     }
 
     email( string time, string address, string subject, string message, integer num_left )
     email( string time, string address, string subject, string message, integer num_left )
     {
     {
    //  if we received an email from an object within Second Life
         if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
         if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
        {//Message was sent from within SL. For this example we will just strip the header.
//     {
             message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
             message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
        }
//      }
       
 
         llSay(0, message);
    //  PUBLIC_CHANNEL has the integer value 0
         llSay(PUBLIC_CHANNEL, message);


    //  if there's another email in the queue waiting
    //  get next email, don't filter by sender or subject
         if(num_left)
         if(num_left)
             llGetNextEmail("", "");
             llGetNextEmail("", "");
     }
     }
}</lsl>
}
</syntaxhighlight>
|helpers
|helpers
|also_header
|also_header
Line 53: Line 64:
|mode
|mode
|deprecated
|deprecated
|haiku={{Haiku|Refulgent cockcrow|A red, full mailbox blows up|near the avatar}}
|cat1=Email
|cat1=Email
|cat2
|cat2

Latest revision as of 11:57, 30 April 2022

Description

! Event: email( string time, string address, string subject, string message, integer num_left ){ ; }

Triggered as a result of calling llGetNextEmail where there is a matching email in the email queue.

• string time In the (string)llGetUnixTime format
• string address
• string subject
• string message
• integer num_left The number of emails remaining in the email queue.[1]

The email queue is associated with the prim and any script in the prim can access it.
The prim's email address is its key with "@lsl.secondlife.com" appended, llGetKey() + "@lsl.secondlife.com"[2].

Specification

The email event is triggered as a result of calling llGetNextEmail when there is an email that matches llGetNextEmail's optional filters. The first email that matches the filters is removed from the email queue and its data is used as the parameters for this event. If no email matches the filters but the queue is not empty this event is not triggered. Besides the effects of filtering, the email queue is FIFO.

Caveats

  • The email queue is limited to 100 emails, any email after that is bounced.
  • The message field may have a maximum of 1000 single-byte characters. This count includes the header information (address, subject, etc).
  • Emails sent from within SL will have their message body prefixed with a header detailing the originating prim. See llEmail for more details.
  • 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 (resetting the script doesn't help).
  • Due to bug BUG-229767, an object's email queue can still become suspended until the object crosses a region border (neither a region restart nor a script reset helps). First analysis has revealed a potential workaround, by implementing a delay of about 30 seconds before first trying to send email to a freshly rezzed script - apparently registering the email(...) event handler can take quite some time, and emails arriving prior to said registry process is what gets the entire queue stuck. Official Linden response still pending.


Examples

default
{
    state_entry()
    {
        llSetTimerEvent(5.0);
    }

    timer()
    {
    //  get next email, don't filter by sender or subject
        llGetNextEmail("", "");
    }

    email( string time, string address, string subject, string message, integer num_left )
    {
    //  if we received an email from an object within Second Life
        if (llGetSubString(address, -19, -1) == "@lsl.secondlife.com")
//      {
            message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
//      }

    //  PUBLIC_CHANNEL has the integer value 0
        llSay(PUBLIC_CHANNEL, message);

    //  if there's another email in the queue waiting
    //  get next email, don't filter by sender or subject
        if(num_left)
            llGetNextEmail("", "");
    }
}

Notes

For tips on how to process emails sent from within SL, see the entry on llEmail.

See Also

Functions

•  llEmail
•  llGetNextEmail

Deep Notes

Issues

All Issues

~ Search JIRA for related Issues
   Region incoming email queue for objects becomes suspended
   llEmail and llHTTPRequest do not handle non-ASCII characters
   Include "Content-Type: text/plain; charset=UTF-8" header in the messages forwarded from second life.
   llEmails to objects not in the same region arrive without a body or do not arrive at all.
   Object-to-object email sporadically fails

Footnotes

  1. ^ The email being processed is not counted as it has already been popped from the queue.
  2. ^ Preview grid email address are constructed differently: llGetKey() + "@lsl." + grid + ".lindenlab.com"; for the main beta grid set grid to "aditi".

Signature

event void email( string time, string address, string subject, string message, integer num_left );

Haiku

Refulgent cockcrow
A red, full mailbox blows up
near the avatar