62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
// inspired by https://www.mailgun.com/blog/email/double-opt-in-with-php-mailgun/
|
|
|
|
// general constants
|
|
$general = array(
|
|
// "domain" => 'tobias-radloff.de',
|
|
"domain" => 'localhost',
|
|
"uniqueKey" => '***REMOVED***', // works like password salt
|
|
"confirmScript" => "/confirm.php"
|
|
);
|
|
$general["siteURL"] = "https://" . $general["domain"];
|
|
|
|
// smtp info
|
|
$smtp = array(
|
|
"host" => '***REMOVED***
|
|
"port" => 587,
|
|
"username" => 'tobias',
|
|
"password" => '***REMOVED***',
|
|
"auth" => TRUE,
|
|
"fromAddress" => "***REMOVED***", // 'newsletter@tobias-radloff.de'
|
|
"fromName" => "Tobias Radloffs Newsletter",
|
|
);
|
|
|
|
$body = array(
|
|
"Hallo!",
|
|
"Bitte bestätige die Anmeldung für meinen Newsletter, indem du auf den folgenden Link klickst:",
|
|
"%confirmURL%", // placeholder
|
|
"Bis bald und viele Grüße, Tobias"
|
|
);
|
|
|
|
// mail contents
|
|
$mail = array(
|
|
"subject" => 'Newsletter-Anmeldung bestaetigen',
|
|
"bodyHTML" => "<p>" . implode("</p><p>", $body) . "</p>",
|
|
"bodyText" => implode("\n\n", $body)
|
|
);
|
|
|
|
// DB constants
|
|
$db = array(
|
|
"host" => "",
|
|
"port" => "",
|
|
"username" => "",
|
|
"password" => ""
|
|
);
|
|
|
|
function SanitizeInputs($var) {
|
|
return htmlspecialchars($var, ENT_QUOTES);
|
|
}
|
|
|
|
function SanitizeEmail ($var) {
|
|
$sane = htmlspecialchars($var, ENT_QUOTES);
|
|
$pattern = "/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/";
|
|
preg_match($pattern, $sane, $res);
|
|
$r = $res[0] ? $res[0] : false;
|
|
return $r;
|
|
}
|
|
|
|
function CheckConfirmationHash($confEmail, $confCode) {
|
|
global $general;
|
|
return (md5($confEmail . $general["uniqueKey"]) === $confCode);
|
|
}
|
|
?>
|