我对这段代码有疑问(这不是我的,但我必须继续努力)。它用于为题字发送邮件确认。但是邮件不是这样发送的。有人可以帮助我吗?非常感谢 !
<?php
class Users extends Model{
var $table="users";
function exist($d){
$existM = $this->find(array("conditions"=>'email="'.$d['email'].'"'));
$existL = $this->find(array("conditions"=>'login="'.$d['login'].'"'));
if($existM || $existL){
return true;
}else{
return false;
}
}
function mail($data){
//ini_set('memory_limit', '1024M');
//ini_set("SMTP","smtp.sfr.fr");
$destinataire = $data['email'];
$sujet = "Activer votre compte";
$entete = "From : Site personnel \n";
$entete .= "MIME-version: 1.0\n";
$entete .= "Content-type: text/html; charset= utf8\n";
$msg='<h1>Bonjour "'.$data['login'].'" ! </h1>
<p>Pour activer votre compte, veuillez cliquer ici</p>
<p><a href="http://www.sylvain-blondin.com/activer?token='.$data['token'].'-'.$data['email'].'">Activer</a></p>';
$sentmail = mail($destinataire, $sujet, $msg, $entete);
if ($sentmail){
echo $this->message("Pour finaliser votre inscription, un mail vous a été envoyé pour activer votre compte.","");
} else{
echo $this->message("Mail non envoyé","");
}
}
}
?>
我在哪里设置 $data
<?php
extract($_POST);
$users = Model::load('Users');
$form = Model::load('Form');
if(isset($_FILES['avatar']) && $_FILES['avatar']['size']>0){
$format = substr($_FILES['avatar']['type'],6,3);
$format_auto = array("gif","png","jpg","jpe");
if(in_array($format, $format_auto)){
$data['avatar'] = $_FILES['avatar']['name'];
$tmp_name = $_FILES["avatar"]["tmp_name"];
$name = $data["avatar"];
move_uploaded_file($tmp_name,"theme/images/avatar/$name");
}else{
echo $users->message("Le format de l'image n'est autorisé","error");
}
}
if(isset($data['login']) && isset($data['password']) && isset($data['password2']) && isset($data['email'])){
if(!empty($data['login']) && !empty($data['password']) && !empty($data['password2']) && !empty($data['email'])){
if($data['password']!=$data['password2']){
$erreur = array('password2' => 'Les mots de passe ne sont pas identiques');
$form->setErrors($erreur);
}else{
if(!$users->exist($data)){
unset($data['password2']);
$data['password'] = sha1($data['password']);
$data['token'] = md5(rand());
$users->save($data);
$users->mail($data);
}else{
echo $users->message("Le login ou l'email est déja utilisé","error");
}
}
}
else{
echo $users->message("Vous n'avez pas rempli tous les champs","error");
}
}
?>