27.01.2012, 11:57
I used the HTTP() function with POST data and a .php file on my website:
The 'passkey' is just so nobody can go to the file in their web browser and send fake e-mails to players. It should be strange and secure, like 'a3re97bas54AG' or something. Not guessable.
Obviously you need to format the string with the relevant data, and this is the .php file:
And I stored the 'randkey' in mySQL.
I used this to generate random keys:
Granted there will be better, more efficient ways of doing this.
pawn Code:
format(string, sizeof(string), "passkey=some_secret_password_that_nobody_can_guess_that_isnt_your_bank_account_password&email=%s&name=%s&key=%s", inputtext, pName[playerid], randkey);
HTTP(0, HTTP_POST , "www.mywebsitesite.com/email_verification.php", string, "MyHttpResponse");
Obviously you need to format the string with the relevant data, and this is the .php file:
PHP Code:
<?php
if($_POST['passkey'] != 'some_secret_password_that_nobody_can_guess_that_isnt_your_bank_account_password') die();
$name = $_POST['name'];
$key = $_POST['key'];
$email = $_POST['email'];
$string = "Hello, $name.<br/><br/>This e-mail was sent to this address as it was provided during registration of an account on the SA:MP server '*****'.<br/>If you do not have a ***** account, please reply to support@*****.net.<br/><br/>If this is your account, please join the server and enter the following code when prompted:<br/><br/><b>$key</b><br/><br/>You will then be able to register.<br/><br/>The ***** Support Team";
$strHeaders = "MIME-Version: 1.0\r\n";
$strHeaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
$strHeaders .= "From: support@*****.net";
mail($email, '*****- E-mail Verification' , $string, $strHeaders);
?>
I used this to generate random keys:
pawn Code:
new randchar[][] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
new randkey[10];
format(randkey, sizeof(randkey), "%s%s%s%s-%i%i%i%i", randchar[random(sizeof(randchar))], randchar[random(sizeof(randchar))], randchar[random(sizeof(randchar))], randchar[random(sizeof(randchar))], random(10), random(10), random(10), random(10));