Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Interpret E-Mails from SL

Jim Bunderfeld
The Coder
Join date: 1 Mar 2004
Posts: 161
02-23-2005 11:58
I have alot of experience with LSL, but not much wiht any other programming/scripting language. How can I make a program that can takes emails sent to it from LSL, and then read them and send them off to a, database I guess, I dunno I very newbish on other languages.

Please help,
Jim
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
02-23-2005 13:50
Perl is my preffered route, off the top of my head, the following will work:

Into /etc/mail/aliases add:
CODE
user: "|/path/to/script.pl"


Then execute at your favourite shell:
CODE
root@system#: newaliases
/etc/mail/aliases: 109 aliases, longest 15 bytes, 970 bytes total


Into /path/to/script.pl (make sure to chmod +x)
CODE
#!/usr/bin/perl

use strict;
use mysql;

my $line;
my $cleanline;
my $db;

$db = Mysql->connect("user","pass","host","database"); # connect to MySQL DB

while($line = <STDIN>) { #read one-line-at-a-time into $line
print "Recieved $line\n";
$cleanline = $db->quote($line); # Protect against SQL Insertion attacks
$db->query("INSERT INTO lines VALUES ($cleanline)");
}

print "Recieved Email.\n";
_____________________
Co-Founder / Lead Developer
GigasSecondServer
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
02-23-2005 14:25
Enter your friend procmail

Example == dreamhost, but I'm sure you could make it work with your host too...
_____________________
Strangeweather Bomazi
has no clever catchphrase
Join date: 29 Jan 2005
Posts: 116
02-24-2005 06:54
BTW, Jim, the above answers only work under Unix or Linux. If you only have access to a Windows machine, you'll need to find an alternate approach.

I'm not sure if there is a way to set up procmail to run on Windows. Another possibility is to write something in VBA for Outlook. I've never done it, though, so I can't offer much help.
_____________________
Strangeweather Designs - classic casual home furnishings
Now open in Mochastyle, Mocha (13, 115)
Jim Bunderfeld
The Coder
Join date: 1 Mar 2004
Posts: 161
02-24-2005 13:05
I have a Linux box I can use, but all of this is still very hazy to me, it really isn't very easy to follow.
Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
Understood...
02-24-2005 14:48
Jim,

I can see how it would be a little confusing if you had never worked with procmail or unix mail in general. Adam's post *should* work properly though. If you follow it closely, there are only a few steps. It does make a few assumptions - that you are root and that MySQL will let you connect from the box and everything.

--

Adam,

doesn't that make a global script? Why not create a user account just for this and use a .procmail inside the directory? Seems like you are limited to one script that way. Did I miss something? Also, default permissions may not let you execute the command properly?


edit - I should read my own advice... I see Adam did say to fix the permissions
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
03-02-2005 13:23
From: Jack Lambert

Adam,

doesn't that make a global script? Why not create a user account just for this and use a .procmail inside the directory? Seems like you are limited to one script that way. Did I miss something? Also, default permissions may not let you execute the command properly?


edit - I should read my own advice... I see Adam did say to fix the permissions



You can add as many scripts as aliases your mail daemon will support without falling in a pile. (I think sendmail has issues once you break 8mB of aliases. :))

Yes, you will need to have root to edit /etc/aliases and run the newaliases application.

Creating a user account for every script is tiresome, and a waste. I have 113 scripts on SecondServer.net, and creating a user for each of them would quickly drive me insane. To add more aliases:

CODE

address: "|/path/to/1.pl"
address2: "|/path/to/2.pl"
... etc.


-Adam
_____________________
Co-Founder / Lead Developer
GigasSecondServer
Trent Hedges
TrentCycle & GRAPHICA
Join date: 4 Sep 2003
Posts: 198
little of-topic...
03-02-2005 21:32
Hey guys...

My experience is in ASP and I'd love to pull off data from SL and stick it in an ODBC connected (or Access) database .

I have looked at the windows email-parsing possibilities - and they're either just plain bad, or very expensive...

anyone have thoughts on this? I have tried a few times to get my head around XML RPC but dont know how to make a connection on a WIN2K box... anyone?
_____________________
TrentCycle - Own the Legend. TrentCycle Callisto
TrentVend - Callisto
GRAPHICA Magazine - Designer and Editor www.slgraphica.com
Cristiano Midnight
Evil Snapshot Baron
Join date: 17 May 2003
Posts: 8,616
03-02-2005 22:31
From: Trent Hedges
Hey guys...

My experience is in ASP and I'd love to pull off data from SL and stick it in an ODBC connected (or Access) database .

I have looked at the windows email-parsing possibilities - and they're either just plain bad, or very expensive...

anyone have thoughts on this? I have tried a few times to get my head around XML RPC but dont know how to make a connection on a WIN2K box... anyone?


Trent,

There are some viable POP3 components available for ASP - but to get higher performance, you should consider going with ASP.NET. The best component I have found for processing email is ASPNETPOP3, in conjunction with the ASPNETMIME component from Advanced Intellect. The combo of the POP3, SMTP, MIME and MX controls is $225 - not a bad deal for the amount of functionality they have. .NET is also much better suited if you want to go the XML-RPC route as well.

I use ASPNETPOP3 to process emails from my vendors - it sends out each transaction as a simple XML string in the email, and dumps it into s SQL server DB. If you need any info let me know :)
_____________________
Cristiano


ANOmations - huge selection of high quality, low priced animations all $100L or less.

~SLUniverse.com~ SL's oldest and largest community site, featuring Snapzilla image sharing, forums, and much more.

Trent Hedges
TrentCycle & GRAPHICA
Join date: 4 Sep 2003
Posts: 198
03-03-2005 08:03
From: Cristiano Midnight
Trent,

There are some viable POP3 components available for ASP - but to get higher performance, you should consider going with ASP.NET. The best component I have found for processing email is ASPNETPOP3, in conjunction with the ASPNETMIME component from Advanced Intellect. The combo of the POP3, SMTP, MIME and MX controls is $225 - not a bad deal for the amount of functionality they have. .NET is also much better suited if you want to go the XML-RPC route as well.

I use ASPNETPOP3 to process emails from my vendors - it sends out each transaction as a simple XML string in the email, and dumps it into s SQL server DB. If you need any info let me know :)



I messaged you in game - but I am very interested in finding out more about this - I really dont know how to get started - my experience is with standard ASP and ODBC connected databases... I'd love to wrap my head around the possibilities you're talking about here - but I think i need a 'tutor' or something :) Please contact me if you have the time and inclination!
_____________________
TrentCycle - Own the Legend. TrentCycle Callisto
TrentVend - Callisto
GRAPHICA Magazine - Designer and Editor www.slgraphica.com