我不能用PHPMailer发送电子邮件

时间:2021-03-11 18:15:30

this my first participation in this forum, i hope that you can help me ...!

这是我第一次参加这个论坛,我希望你能帮助我......!

the problem is i can't send e-mails using PHPmailer

问题是我无法使用PHPmailer发送电子邮件

Code :

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;
    }   
}

}

and result is False

结果是假的

NB : i already configured SMTP authontification in PHPMailer Class

注意:我已经在PHPMailer Class中配置了SMTP authontification

for information, my website is DEMO and i put it in a subdirectory (www.domain.com/subdirectory)

有关信息,我的网站是DEMO,我把它放在一个子目录(www.domain.com/subdirectory)

1 个解决方案

#1


0  

Try to use $this->oMailer->SMTPDebug = SMTP::DEBUG_LOWLEVEL; //SMTP::DEBUG_LOWLEVEL=4

尝试使用$ this-> oMailer-> SMTPDebug = SMTP :: DEBUG_LOWLEVEL; // SMTP :: DEBUG_LOWLEVEL = 4

this value outputs much more infomation about possible error

此值输出有关可能错误的更多信息

#1


0  

Try to use $this->oMailer->SMTPDebug = SMTP::DEBUG_LOWLEVEL; //SMTP::DEBUG_LOWLEVEL=4

尝试使用$ this-> oMailer-> SMTPDebug = SMTP :: DEBUG_LOWLEVEL; // SMTP :: DEBUG_LOWLEVEL = 4

this value outputs much more infomation about possible error

此值输出有关可能错误的更多信息