Ik heb een script gevonden om op een e-mail adres aan te bieden aan ezmlm om te (un)subscriben op een mailinglijst.
if($_POST['action'] == 'join') {
$to='tyche-subscribe-'.str_replace('@','=',$from).'@domein.org';
$body = 'subscribe';
if($from != "" && $to != "") {
$headers .= "X-Mailer: php\n";
$headers .= "From: " . $from . "\n";
mail($to, $subject, $body, $headers);
print 'Check your e-mail inbox now! You should have received instructions via email on how to finish subscribing.';
}
} elseif($_POST['action'] == 'leave') {
$to='tyche-unsubscribe-'.str_replace('@','=',$from).'@domein.org';
$body = 'unsubscribe';
if($from != "" && $to != "") {
$headers .= "X-Mailer: php\n";
$headers .= "From: " . $from . "\n";
mail($to, $subject, $body, $headers);
print 'Check your e-mail inbox now! You should have received instructions via email on how to finish unsubscribing.';
}
} else {
}
?>
<form name="lijst" method="post" action="<? echo $PHP_SELF; ?>"
Dit werkt, maar beschikt niet over e-mail validatie. Ik vond hier wel een script maar ik krijg het niet werkend gekoppeld.
Validatie script
<?php
function email_validator($email)
{
$email_host = explode("@", $email);
$email_host = $email_host[1];
$email_resolved = gethostbyname($email_host);
if($email_resolved == $email_host)
{
$valid = FALSE;
}
if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email))
{
$valid = TRUE;
}
else
{
$valid = FALSE;
}
return $valid;
}
$check_email = email_validator($mail_variabele);
if ($check_email == FALSE)
{
echo "Ongeldig e-mail adres.";
}
else
{
echo "Geldig e-mail adres.";
}
?>
Ik wil natuurlijk geen echo maar een stop van de verzending van de subscribe request. Kan iemand mij helpen? Bij voorbaat dank.
567 views