Jump to content

how to send email using php codes for account activation?


jcaptain007

Recommended Posts

Here's how I do it: Send an email with the sha1 hash of the email and a phrase only the webserver knows.

An example (untested):

<?php
$secret = 'watermelon'; //Change this to something long and complicated
$email = $_GET['email']; //Clean this variable first!
$hash = sha1($email.$secret);
$mailText = "To validate, click here: http://example.com/step2.php?email=$email&hash=$hash";
//Then use mail() or whatever to send $mailText
?>

And on step2.php

<?php
$secret = 'watermelon'; //Same as in the last script
$email = $_GET['email']; //Clean this variable first!
$hash = sha1($email.$secret);
$theirHash = $_GET['hash'];
if ($hash == $theirHash){
    //Add to your email list or whatever
}
?>

This is how xkcdmailer works, except the secret is a random number generated every 15 minutes, and stored in a text file blocked from clients using .htaccess.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.