简体   繁体   中英

i can't send E-mail with PHPMailer

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM