25 Nov, 2009, jurdendurden wrote in the 1st comment:
Votes: 0
Now I'm on to implementing a way of sending email through the mud to a player who has lost their password, i'm trying to do this using mailx via a system call but I can't seem to get the syntax correct; it compiles fine but the email never seems to send. here is the code, any ideas?
void do_email_pw(CHAR_DATA *ch, char *argument)
{
char *pw;

if (IS_NPC(ch))
return;

pw = ch->pcdata->pwd;

system("mailx -s pw blah@gmail.com");
return;
}
25 Nov, 2009, JohnnyStarr wrote in the 2nd comment:
Votes: 0
I think its cool, but I would consider:
Is it safe?
Also, will it work on multiple platforms?
Of course, that may not matter if you dont plan on releasing your project.
25 Nov, 2009, jurdendurden wrote in the 3rd comment:
Votes: 0
Well not that you can tell from my prototype, but eventually i will request a player's email in creation, store it in their pfile, then the do_email_pw function will be a non-malleable function, meaning that the code will do all the work (no one will be able to send each other email of course.), so in that sense it should be fairly safe. Now cross-platform capability shouldn't matter should it, being that the mud is running on a linux box? Using the mailx command server side shouldn't have any problems sending email to someone using a Windows machine because the command is executed server side, correct?
25 Nov, 2009, JohnnyStarr wrote in the 4th comment:
Votes: 0
What I meant by cross platform compatible was if you are going to release your code
to the community, then it would matter. Like I said before, this is probably not an issue if your
code is going to be private.
25 Nov, 2009, jurdendurden wrote in the 5th comment:
Votes: 0
Ahh my fault I didn't understand fully what you meant :)
25 Nov, 2009, Scandum wrote in the 6th comment:
Votes: 0
There's a snippet containing some emailing code that might be of use.

http://www.mudbytes.net/index.php?a=file...
25 Nov, 2009, kiasyn wrote in the 7th comment:
Votes: 0
25 Nov, 2009, jurdendurden wrote in the 8th comment:
Votes: 0
That ruby script looks really cool but I know nothing about ruby… would I be patching that into the mud's code, or compiling it on the linux box and making a call to it via the system command from within the mud?
25 Nov, 2009, kiasyn wrote in the 9th comment:
Votes: 0
You could communicate with it like this:
#include <stdlib.h>
#include <stdio.h>

void send_email( const char *to, const char *from, const char *subject, const char *data )
{
FILE *fp;

if ( ( fp = popen( "ruby1.9 /path/to/sendemail.rb", "w" ) ) == NULL ) {
fputs( "Couldn't connect to sendmail script.\n", stderr );
exit( EXIT_FAILURE );
}
fputs( from, fp );
fputs( to, fp );
fputs( subject, fp );
fputs( data, fp );
pclose( fp );
}

int main()
{
send_email( "noreply@example.org", "noreply@example.org", "test email", "email contents" );
exit( EXIT_SUCCESS );
}


Or you could write your email to a file, in the format:
<from>\n
<to>\n
<subject>\n
<data>


and then pass that as an argument
system( "ruby1.9 /path/to/sendemail.rb < email_file" );
25 Nov, 2009, jurdendurden wrote in the 10th comment:
Votes: 0
Aha, sweet, I had kinda figured it would be something to that effect, thank you very much I'm going to try it out right now, I'll let you know in just a bit! :D
25 Nov, 2009, Mudder wrote in the 11th comment:
Votes: 0
This is pretty cool. A great example too. Definitely bookmarking this for a later date.
25 Nov, 2009, David Haley wrote in the 12th comment:
Votes: 0
Kiasyn's code is good if you want something quick and easy, but do note that it will not work with mail servers that implement greylisting: deliberately telling the sender to retry later. Why does this tactic work? Precisely because the vast majority of spambots use code not too different from Kiasyn's, and therefore never come back later. More and more mail servers implement greylisting, so it's not a negligible consideration. The "right" (as in robust, protocol-respecting) solution is to either talk to the system-level SMTP server, or implement a server that is only slightly smarter and does things like retrying messages until they're actually sent.
25 Nov, 2009, JohnnyStarr wrote in the 13th comment:
Votes: 0
On a side note, I think that it's a good idea to store a players email, but some muds take
it so far, that you have to wait to get a response in order to login. I know when I was a player
looking for a place to "hang my sword", I was always upset when a mud looked cool, but I had
to jump through hoops to give it a try out.

EDIT: This isn't directed at anyone in particular. I just was wondering why some muds do this.
Are they worried about the random spammer? Just curious.
25 Nov, 2009, David Haley wrote in the 14th comment:
Votes: 0
Empirically speaking from an admin's perspective, Darkstone's policy of forcing account activation via email cost us many, many players who never bothered finishing the process. If we were interested in going active again, reworking the account system would be very, very high on my list of things to do for this reason among others.
25 Nov, 2009, Runter wrote in the 15th comment:
Votes: 0
This isn't really a thread asking for policy advice but I would not make email registration mandatory until a certain amount of play. Be it hours or levels.
25 Nov, 2009, jurdendurden wrote in the 16th comment:
Votes: 0
Well I was thinking of setting it up to where they could enter an email if they wanted, but if not they will not have the 'lost password' option available to them.
25 Nov, 2009, Skol wrote in the 17th comment:
Votes: 0
I actually use the email password thing on mine, every once in a long while it seems that people go 'screw you!' but it seems most don't mind. The email is instantly sent and has a lot of good info on the character, as well as 'how to' for beginners.

I haven't done a 'resend password' yet, but might. Hard thing is that some change emails and have character 6-10 years old with old emails, manual patch etc could work but most just note the staff on an alternate char.
25 Nov, 2009, jurdendurden wrote in the 18th comment:
Votes: 0
Ok so apparently the issue this whole time has been that cygwin does not come with sendmail or mailx. Yay. And the smtp progs it comes with are not well documented. So, any other ideas? :P Does anyone know of a good smtp program for cygwin?
25 Nov, 2009, quixadhal wrote in the 19th comment:
Votes: 0
Requiring a valid email isn't so bad, but I'd automate the process of validating it. If you can integrate with a web server, you can just send out an email to the address they give and have them click the link that you generate, that's pretty standard nowadays. A simple MD5 of the email address + timestamp is probably good enough as a unique key.

If they go to that link, the web server's script just ticks a "validated" bit in their player file and you're done.

Bonus points if you have a forum or other resources on the web server, so people who register on that are automatically validated for creating new characters (extra bonus points if your mud uses an account system).

You can write a simple mail client easily enough… just open a socket to your preferred MTA (whatever your mail server is for windows people, probably your ISP), then use the SMTP protocol.
Essentially:

HELO mud@spam.net
MAIL FROM: mud@spam.net
RCPT TO: victim@game.org
DATA
This is some email spam for you!
.
QUIT

The trick is, you have to receive the responses from the mail server before you can send the next segment, otherwise it will probably give you a out of sync error and drop the connection.

In the old days, you could connect directly to their mail server and not only send from there, but RCPT used to be a way to validate that a given username existed. Now, not so much, since most MTA's don't trust you (with good reason).

EDIT: Oh, and ignore the \[email]tags the forum added. :)[/email]
26 Nov, 2009, David Haley wrote in the 20th comment:
Votes: 0
Well, not to be repetitive, but actually in my experience requiring an email to create characters will cost you players – regardless of the ease of validation. It would be much better IMO to make the email as optional as possible, or let them play for a while without one if you really insist that all normal characters have email addresses.
0.0/21