SRL Archive - SRL Snippets

SendEmail


Turpinator

2013-01-10 22:16:35

Thanks to work by my friend OrangeCrush (https://github.com/OrangeCrush), I have been able to make this little function.
Also, John for the original idea on this.

Most of the credit goes to OrangeCrush because hes the one who helped with the anti-login portion, made the anti-spam portion, and interfaced/setup everything. It uses NodeMailer by andris9 to send the mail.

What does it do?
Well, it allows for you to send an email to a specific address. Its pretty neat.

What can I use this for?
For any number of things included but not limited to: errors, level up notifications, etc.
Main usage – SMS Text Messages to mobile phones. Check here to find out how to text you phone.

What can't I use this for?
Spam and sending people's login info (server has spam checks and some login checks)

Can I have the source code for the actual code that sends the mail?
Short answer: No (pm me and i may let you in on the secret)
Unfortunately, I cant release the source from the actual web portion of this as (1) I have no idea how it works or how to get the actual source files and (2) then everyone would be able to see the anti-login information portion and then it could easily be bypassed. (if you'd really like it I can look into getting this)

Actual Function:
Procedure SendEmail( address, message : String );
var
x : Integer;
sBuff, SafeMask : String;
Begin
//-----Message/URL Encoding---Written by BenJones on lazarus.freepascal.org-----
SafeMask := '0123456789abcdefghijklmnopqrstuvwxyz*@._-';
sBuff := '';
For x := 1 to Length(message) Do //Iterate over the entire string
Begin //Check if we have a safe char
If (pos(message[x], SafeMask) > 0) Then sBuff := sBuff + message[x]
Else If (message[x] = ' ') Then sBuff := sBuff + '+' //Append space
Else sBuff := sBuff + '%' + IntToHex(Ord(message[x])); //Convert to hex
End;
//----End URL Encode------------------------------------------------------------
If GetPage('http://webhost1.hp.af.cm/path?a=' + address +
'&m=' + sBuff) = '' Then
WriteLn('Attempted to send "' + message + '" to ' + address +
', but we were unable to reach the webhost to send it')
Else
WriteLn('"' + message + '" sent to ' + address)
End;

Usage:
.
SendEmail('email@email.com','Your Bot has encountered an error');
.

and if you want to just write your own function, but still use the online sendmail portion of this, youll need this URL:
http://webhost1.hp.af.cm/path?a=ADDRESS&m=MESSAGE
Note: Remember to encode your text to URL friendly text, ie SPACE needs to be written %20.

Justin

2013-01-10 22:25:12

Would be good if you could post the php source as we are a open-source community.

Turpinator

2013-01-10 22:38:56

From: Justin
Would be good if you could post the php source as we are a open-source community.


But then the login info detection could easily be bypassed. :(

OrangeCrush said the online portion of it was also added to his Hermes project (https://github.com/OrangeCrush/hermes)

DannyRS

2013-01-10 22:42:45

From: Turpinator
But then the login info detection could easily be bypassed. :(

OrangeCrush said the online portion of it was also added to his Hermes project (https://github.com/OrangeCrush/hermes)


If u randomized letters (basic encrypt decrypt concept) and removed @ symbols etc, how could it tell anyway? Bad idea imo, even worse unless you make it open source

Turpinator

2013-01-10 22:46:08

From: DannyRS
If u randomized letters (basic encrypt decrypt concept) and removed @ symbols etc, how could it tell anyway? Bad idea imo, even worse unless you make it open source


Already thought about that and if someone goes through the trouble to encrypt and decrypt someones' login info, then they should have enough knowledge to get a php mailer script uploaded and they wouldnt need this in the first place.
This is just for those who either dont have time or dont have enough knowledge do make a php mailer script.

Echo_

2013-01-10 22:47:45

It would be better if this was done completely in Simba.

Justin

2013-01-10 23:16:04

Why use a gmail account when you can use the php mail() function?

Turpinator

2013-01-10 23:29:06

From: Justin
Why use a gmail account when you can use the php mail() function?


php mail() gets blocked by spam filters sometimes. (according to my friend)
and i had just asked him to make/setup some sort of online mailer because i dont have the knowledge/motivation to make one.

John

2013-01-10 23:32:29

Good work :)


I have mine finished, It does basically the same stuff but is more Simple, PM me if you want to see the code.

Kyle Undefined

2013-01-14 11:12:27

The only reason why mail gets blocked by spam filters is the content or the IP of the sender. Not because of the mail() function.

nickdean

2013-02-25 09:17:28

On your webhost you can setup a simple PHP file to send your emails.

mailme.php?email=a@a.com&r=itisme44&message=yourmessage
<?php
$randomstring=$_GET['r'];
if ($randomstring=='itisme44'){
$email=$_GET['email']; //or hard code your email
$message = $_GET['message'];
mail($email,"Its Me, Your Bot", $message);
}
?>

superuser

2013-02-25 09:32:39

Or even better, you could use PHPMailer!

grats

2013-02-25 09:33:36

From: Turpinator
php mail() gets blocked by spam filters sometimes. (according to my friend)
and i had just asked him to make/setup some sort of online mailer because i dont have the knowledge/motivation to make one.


more like all the time, especially if it isn't a white listed mail server

php mail() uses the same thing, all mail servers use.. it's just the php function for it. I like smtp using google is much better and faster in most cases.

I think it is a pretty cool idea, just to go along with the topic all phones have an email address associated with them, it's like your phone [email]number-etc@phoneprovider.whatev[/email]er

I had an idea for an automated way to find it, but too much work on the carrier email parts, it finds out what the phone number belongs to and gets that email.. I had a script years ago that I could email my server and it would text(email my phone) back and give me the weather for whatever zip code I emailed it.. it was before smartphones were so popular (even today I don't have a smartphone, I guess I just don't care about the weather as much because I don't go outside anymore) anyway there are lots of cool uses for the phone email if the user only has text capabilities and no internet and even if they do

I think it's pretty cool that you added it for simba, maybe in the future if 2007scape never gets updated and we got bots for everything in existence we can make a script that does multiple things like woodcutting, combat, fire making etc and you can text it and tell it what to do, so it switches to different tasks whenever you say

xtrapsp

2013-02-25 11:43:32

I'm pretty sure I explained this to John?

Anyway gz on release

Turpinator

2013-02-25 13:11:22

From: xtrapsp
I'm pretty sure I explained this to John?

Anyway gz on release


This was at the same time John had asked you about it probably. He had came to me because of a player owned port timer i had made that sent text/email messages and wanted to know about script implementation.

While this 'snippet' doesnt really even use simba to send the email (except encoding it which i dont think is even required), and its not really something that would be added to SRL, it was really for my use/John's and i decided i would post it for anyone else who might want to add email notifications with little to no effort.

John

2013-02-25 15:59:36

Mine just goes to a url on my site with your email and what you want it to say and the page sends the message to your email.

It's a simple GetPage();

Echo_

2013-02-25 21:00:39

This could be done completely in Simba if we had access to the Synapse library already included for functions like GetPage and etc. I tried to do this just using sockets at one point but had no way of initializing a TLS session (which GMail and other mail providers require).

Press Play

2013-03-02 20:12:13

For SRL Members, there's a tut on our upper boards (really really old) that still works :) I'm using it now. You can use it to send messages from Simba to an email. Unfortunately, it requires php - the code is all open-source:

http://villavu.com/forum/showthread.php?t=47589