Skip to content

Instantly share code, notes, and snippets.

@YohannParis
Created January 31, 2013 15:36
Show Gist options
  • Save YohannParis/4683745 to your computer and use it in GitHub Desktop.
Save YohannParis/4683745 to your computer and use it in GitHub Desktop.
Basic email functions for registration system
<?php
// ================================================================================= //
// Email forgot password
// Arguments:
// - email: email address we try to verify
// - verificationNumber: number send to the user to compare
// ================================================================================= //
function emailPassword($email){
$title = 'Forgot Password';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "From: XXXXXXXX <contact@example.ca>\r\n";
$verificationNumber = getEmailVerif($email);
$link = '<a href="'.URL.'forgotPassword.php?email='.$email.'&verifNumber='.$verificationNumber.'">
'.URL.'forgotPassword.php?email='.$email.'&verifNumber='.$verificationNumber.'</a><br />';
$body = '<h1>Thank you for resetting your password</h1>
<p>
To verify your email and confirm your request please click the link below:<br />
'.$link.'<br />
Having trouble? Copy and paste the link into your browser or <a href="'.URL.'contact.php">Contact us</a>.<br />
Not you? <a href="'.URL.'contact.php">Contact us</a>.
</p>';
mail($email, $title, $body, $headers);
}
?>
<?php
// ================================================================================= //
// Email verification after register
// Arguments:
// - email: email address we try to verify
// - verificationNumber: number send to the user to compare
// ================================================================================= //
function emailVerification($email, $verificationNumber){
$link = '<a href="'.URL.'verifUser.php?email='.$email.'&verifNumber='.$verificationNumber.'">
'.URL.'verifUser.php?email='.$email.'&verifNumber='.$verificationNumber.'</a>';
$title = 'Registration confirmation';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "From: XXXXXX <contact@example.ca>\r\n";
$body = '<h1>Thank you for creating a XXXXXXXX account!</h1>
<p>
To complete the registration, you must verify your email address by clicking on the link below:
</p><p>
'.$link.'
</p><p>
Having trouble? Copy and paste the link into your browser or contact us at: (123) 455-7890 or <a href="'.URL.'contact.php">Contact us</a>.
</p>';
}
$body .= '
<p>
Thank you!
</p>
<br />
<p>
XXXXXXXX Team<br />
(123) 455-7890<br />
contact@example.ca<br />
</p>
';
mail($email, $title, $body, $headers);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment