1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| $to = $email;
$sujet = "Activation de votre inscription à la newsletter";
$entete = "MIME-Version: 1.0\r\n";
$entete .= "Content-type: text/html; charset=UTF-8\r\n";
$entete .= "From: root@localhost" . "\r\n".
"Replay-To: root@localhost" . "\r\n".
"X-Mailer: PHP/".phpversion();
$body ='<html><body><head><style>';
$body .='.ligne{color:#003376;font-size:16px}';
$body .='.foo{font-weight:bold;color:#033f9a;}';
$body .='</style></head><center><table>';
$body .='<tr><td class="ligne">
Madame, Monsieur,<br/>
Vous venez de créer un compte sur le site xxxxxx.fr.<br/>
Pour activer ce compte, merci de cliquer sur le lien ci-dessous :<br/>
<a href="$path/validate.php?email=$email&string=$string">
Je valide mon inscription
</a> </td></tr>';
$body .='<tr><td class="ligne">
Vous disposez de 48h pour activer votre compte.<br/>
Si vous n\'êtes pas à l\'origine de cette demande, veuillez ne pas tenir compte de
ce message, le compte sera automatiquement supprimé.<br/><br/>
Bonne lecture,<br/></td></tr>';
$body .='<tr><td class="foo">Votre équipe xxxxxx.fr</td></tr>';
$body .='</table></center></body></html>';
function smtpmailer($to,$sujet,$body,$entete){
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'monemailgmail@gmail.com';
$mail->Password ='monpasswordgmail';
$mail->Subject = $sujet;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()){
$error = 'Mail error'.$mail->ErrorInfo;
return false;
}else{
$error='Mail envoyé avec succès';
return true;
}
$mail->SmtpClose();
unset($mail);
}
smtpmailer($to,$sujet,$body,$entete);
echo "Pour valider votre inscription à la newsletter, un lien d'activation vous a été envoyé à votre adresse mail."; |
Partager