sending mail?

Hello texters :-)

Is there a way to send an email from inside a game?

I mean a real IRL mail, which ends up in a mail server somewhere.

BR
Benny


You might be able to send mail with javascript sockets, but you'd need to have an email account set up on some server, and include the password within the game code. That's likely a very bad idea.
Or prompt the player for their mailserver and and username/password … I think few players would be willing to do that.

I can't see any reason you'd want to send email from within a game. Maybe if you tell us what you're hoping to do with it, someone could suggest a workable solution.


Hello.

This may help:

http://textadventures.co.uk/forum/samples/topic/j9evupa4h0c6ua7_bh9twa/reporting-a-bug-from-in-game-via-email-an-example


Yeah.

I am an old man.
I was kind of thinking about things USED to be, where you could just open a socket on port 25 and post transmit some SMTP.
But of course these days that would be blocked by all kind of antispam solutions :-)
(Oh yes. Those were the days :-))

So you are of course right.
It is probably not a good idea.

I am working on a game specifically for my grandson.
It is a spy thriller.
There is going to be a lot of feelies and stuff like smsing IRL to secret phonenumbers, secret mail accounts, physical codebooks etc.
And I was considering an idea of having the game send an email behind the scenes at certain points during the game, so I (IRL) could keep track of how far he has gotten, to send him interrupting messages on sms or email :-)

It is still early days :-D


And I was considering an idea of having the game send an email behind the scenes at certain points during the game, so I (IRL) could keep track of how far he has gotten, to send him interrupting messages on sms or email :-)

In that case, you don't really need it to be email. Set up a webform somewhere, that the game can post to.


You can call a PHP-Skript to send an email. Here is an example of a javascript function that calls a PHP skript (not tested). In the next version of Quest (I hope) you will have a new internal function to call PHP scripts.

function SendMail(text, to) {
   var url = "http://www.yourserver.com/email.php?text="+ text + "&to=" +to ;
   var xmlHttp = null;
   xmlHttp = new XMLHttpRequest();
   if (xmlHttp) {
      xmlHttp.open('POST', url, true);
      xmlHttp.send(null);
    }
}


@Pertex
Probably more efficient to put the text in a POST request, to avoid a lot of hassle with escaping.

function SendMail(text, subject, to) {
  email = "To: "+to+"\nSubject: "+subject+"\n\n"+text;
  $.post("http://www.yourserver.com/email.pl", email);
}

Just requires a PHP script that supports input in that form; which should take about 3 minutes to write.

(I'm not good with PHP, but here's an example Perl script that you could run on the server)

#!/usr/bin/perl
my $message;
my $to;
while(<>) {
  my $message .= $_;
  if (/^To:\s*([^']+?)\s*$/) {
    $to = $1;
  }
}
if ($to) {
  // probably want to check the recipient address here
  // to prevent spambots abusing it
  open(MAIL, "|-", "sendmail", $to) or die ("Couldn't launch sendmail");
  print MAIL $message;
  close MAIL;
}

(Or don't use a PHP script at all; it takes about 15 minutes to make exim accept email submission over HTTP-POST like that, only for a specified list of recipients)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums