Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Emails through OpenSim

BertronVII Hammerthall
Registered User
Join date: 27 Mar 2009
Posts: 10
03-27-2009 04:07
Hey all! I'm currently working on a virtual reality project at uni and I've come up against a rather annoying challenge which I can't seem to get my head around... I'd like to be able to send an email from my OpenSim environment. I've tried simply using the llEmail function, using my Gmail SMTP account as the middleman, but that doesn't seem to work... Ideally I'd like to be able to use the llEmail function due to it's simplicity.

Instead, I've adopted the following system:

//This is the script I'm currently using. I've written a test HTML page to called the .aspx page featured by the url parameter, that works perfectly and parses the correct parameters. However, when I parse the same information via an llHTTPRequest in OpenSim, nothing seems to happen, upon checking the HTTPResponse, (200 which is fine) I'm left a little puzzled but should let you know that I'm using IIS7.0 on Vista, I don't know if that shoots me in the fact as far as being able to talk to a .aspx page from Second Life...

default
{
touch_start(integer total_number)
{
string url =
"http://localhost/EmailPortal/default.aspx";

string formData =
"emailTo=aaa&emailFrom=bbb&emailSubject=ccc&emailBody=ddd";

llHTTPRequest(
url,
[HTTP_METHOD, "GET"],
llUnescapeURL(formData));
}

http_response(key request_id, integer status, list metadata, string body)
{
llSay(0, (string)status);
}
}

//This is the script I'd ideally like to use:

default
{
touch_start(integer total_number)
{
llEmail("aaa@bbb.com", "Subject", "Body" );
}
}

My OpenSim.ini reads:

; ##
; ## EMAIL MODULE
; ##

;emailmodule = DefaultEmailModule

[SMTP]

enabled=true

internal_object_host=lsl.opensim.local
host_domain_header_from=127.0.0.1
SMTP_SERVER_HOSTNAME=smtp.gmail.com
SMTP_SERVER_PORT=25
SMTP_SERVER_LOGIN=xyzzx@xyzzx.com
SMTP_SERVER_PASSWORD=xyzzx

Is there something I'm completely missing? There are no exceptions being thrown because successive lines of code execute fine and I don't get the red error message towards the left of my screen... I've tried uncommenting the emailmodule line, but that seems to make my OpenSim complain when it it's starting up...

I'm stumped ^_^

Any help would be GREATLY appreciated!


Rob
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
03-27-2009 06:58
not really sure on this, but have you tried using a php script as the middleman instead?
BertronVII Hammerthall
Registered User
Join date: 27 Mar 2009
Posts: 10
03-27-2009 07:15
I'm using a .aspx page due to the fact that I'm familiar with the code behind it (C# in this case), I'm writing the parsed parameters (namely from the keys emailTo, emailFrom, emailSubject and emailBody) to a file on the server computer (in this case my computer during development).

I don't have any experience using PHP unfortunately. I did consider using it and knocked up a very simple PHP page, but if I'm honest, I didn't really know what it did (or why it didn't do that) lol
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
03-27-2009 07:58
GMail requires TLS to be enabled when sending mail via SMTP or IMAP, and doesn't use port 25. Also, you need to enable POP from the GMail account's settings, etc., etc. : http://mail.google.com/support/bin/answer.py?hl=en&answer=13287 and http://mail.google.com/support/bin/answer.py?hl=en&answer=78775


.
_____________________
BertronVII Hammerthall
Registered User
Join date: 27 Mar 2009
Posts: 10
03-27-2009 08:18
Thanks for your advice, I've now tried using port 465 and 587 (the other ports recommended by Gmail) but neither of them worked...

Is there anything fundamentally squiffed with the following?

; ##
; ## EMAIL MODULE
; ##

emailmodule = DefaultEmailModule

[SMTP]

enabled=true

internal_object_host=lsl.opensim.local
host_domain_header_from=127.0.0.1
SMTP_SERVER_HOSTNAME=smtp.gmail.com
SMTP_SERVER_PORT=25 (And other ports obviously)
SMTP_SERVER_LOGIN=emailaddress@gmail.com
SMTP_SERVER_PASSWORD=password

My call is (pseudocode):

llEmail("emailaddress@gmail.com", "Subject", "Body";);
BertronVII Hammerthall
Registered User
Join date: 27 Mar 2009
Posts: 10
03-27-2009 08:19
Sorry to yap on, I really do appreciate the help!
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
03-27-2009 08:36
I'm not familiar enough with OpenSIM configuration to know whether it supports TLS, but I do know that when I've enabled sending email through GMail in other applications I've had to specifically enable TLS to get things working.

If you cannot enable this directly from the OpenSim configuration, you might go back to using an aspx page as intermediary, and using something like the Chilkat email components: http://www.example-code.com/csharp/sendSecureStartTLS.asp

Alternatively, you could roll your own with some fairly basic SMTP code (http://www.osix.net/modules/article/?id=513) and use the Mentalis socket classes to enable TLS (http://www.mentalis.org/soft/projects/ssocket/). I've done the latter in the past, but was not able to locate sample code for you on this machine.

Good luck, I hope you get things working!


.
_____________________
BertronVII Hammerthall
Registered User
Join date: 27 Mar 2009
Posts: 10
03-27-2009 09:47
Thanks for your help, I've decided to go with the "simple" .aspx page now... Getting Gmail configured to forward emails I'm not even sure it's going to receive in the first place isn't the most rewarding feeling! From here on in it's "just" a case of performing a llHTTPRequest:

llHTTPRequest("http://localhost/mywebsite/default.aspx", [HTTP_METHOD, "GET"], llUnescapeURL(formData));

Which OF COURSE doesn't work, but it's a smaller task!
BertronVII Hammerthall
Registered User
Join date: 27 Mar 2009
Posts: 10
03-27-2009 10:08
SOLVED! ^_^ I've been treating the parameters differently to the url, combining the two has solved my problem! PHEW :D

default
{
touch_start(integer total_number)
{
string url = "http://localhost/EmailPortal/default.aspx";
string params = "?emailTo=emailto@gmail.com&emailFrom=emailfrom@gmail.com&emailSubject=OMGITWORKS&emailBody=OMGITSTILLWORKS";
llHTTPRequest(url + params, [HTTP_METHOD, "GET"], "";);
}

http_response(key request_id, integer status, list metadata, string body)
{
llSay(0, (string)status);
}
}

Thank you for your kind support throughout the day!

Take care

Rob (BertronVII)