这是我第一次参加这个论坛, 我希望你能帮助我......!
问题是我无法使用PHPmailer发送电子邮件
代码:
class Controller_Mail extends Controller_Template{
protected $oMailer;
public function __construct()
{
$this->oMailer = new PHPMailer(true);
}
//Envoyer Password Oublie à un candidat
public function EnvoyerPasswordOublie(Class_Candidat $objCandidat){
try {
$nom = $objCandidat->getNomPrenom() ;
$password = $objCandidat->getPassword() ;
//$toMailCandidat = $objCandidat->getMail() ;
$toMailCandidat = "amaljob@gmail.com" ;
$subject = "Mot de passe oublié !" ;
$message = "Cher (e) <b>".html($nom)."</b>,<br/> <br/>
Suite à votre demande, veuillez trouver ci-dessous votre identifiant et votre mot de passe, vous permettant d'accéder à votre espace :<br/><br/>
Email : ".html($toMailCandidat)."<br/>
Mot de passe : ".$password."<br/><br/>
Cordialement,,<br/><br/>
L’Equipe ".ABREV ;
//$message = templateStringCandidat($message) ;
$message = "message" ;
$this->oMailer->IsSMTP();
$this->oMailer->SMTPAuth = true;
$this->oMailer->SMTPDebug = 2;
$this->oMailer->Port = 485;
$this->oMailer->FromName = ABREV;
$this->oMailer->From = MailsFrom;
$this->oMailer->AddAddress($toMailCandidat);
$this->oMailer->AddAddress(MailNotifications);
$this->oMailer->AddReplyTo(MailsFrom,ABREV);
$this->oMailer->Subject = $subject;
$this->oMailer->MsgHTML($message);
$this->oMailer->IsHTML(true); // send as HTML
if(!$this->oMailer->Send()) {
return 'erreur : '.$this->oMailer->ErrorInfo;
} else {
return true;
}
} catch (phpmailerException $e) {
return false;
}
}
}
,结果为假
注意:我已经在PHPMailer Class中配置了SMTP authontification
有关信息,我的网站是DEMO,我把它放在子目录中(www.domain.com/subdirectory)
答案 0 :(得分:0)
尝试使用$this->oMailer->SMTPDebug = SMTP::DEBUG_LOWLEVEL; //SMTP::DEBUG_LOWLEVEL=4
此值输出有关可能错误的更多信息