I'm facing this error msg when I tryed to send email using PHPMailer

If anyone or ready see this error pls help me

Erro na Linha: #3 :: require(…/Library/PHPMailer/class.phpmailer.php): failed to open stream: No such file or directory
D:\wamp\www\brzeladoria\zeladoriapatrimonial_apps\Models\Email.class.php

either you have PHPMailer not installed or you’re looking in the wrong place.

ideally, you install it through Composer, which will handle class loading for you.

Hi Dormilich I have PhpMailer Installed

Then you’re looking for it in the wrong place.

Note: the place you try seems to be D:\wamp\www\brzeladoria\zeladoriapatrimonial_apps\Library\PHPMailer\class.phpmailer.php, don’t know if that’s right.

This is my class for call the PHPMailer and for send email

<?php

require ('../Library/PHPMailer/class.phpmailer.php');

/**
 * Email [ Model ]
 * Modelo respomsável por configurar a PHPMailer, validar os dados e disparar e-mails do sistema.
 * @copyright (c) 2016, Lopes Boa ANGONEWS ENTERPRISE
 */
class Email {

   /** @var PHPMailer */
    private $Mail;

    /** EMAIL DATA */
    private $Data;

    /** CORPO DO E-MAIL */
    private $Assunto;
    private $Mensagem;

    /** REMETENTE */
    private $RemetenteNome;
    private $RemetenteEmail;

    /** DESTINO */
    private $DestinoNome;
    private $DestinoEmail;

    /** CONSTROLE */
    private $Error;
    private $Result;

    function __construct() {
        $this->Mail = new PHPMailer;
        $this->Mail->Host = MAILHOST;
        $this->Mail->Port = MAILPORT;
        $this->Mail->Username = MAILUSER;
        $this->Mail->Password = MAILPASS;
        $this->Mail->SMTPSecure = "ssl";
        $this->Mail->CharSet = 'UTF-8';
    }

    /**
     * <b>Enviar E-mail SMTP:</b> Envelope os dados do e-mail em um array atribuitivo para povoar o método.
     * Com isso execute este para ter toda a validação de envio do e-mail feita automaticamente.
     * 
     * <b>REQUER DADOS ESPECÍFICOS:</b> Para enviar o e-mail você deve montar um array atribuitivo com os
     * seguintes índices corretamente povoados:<br><br>
     * <i>
     * &raquo; Assunto<br>
     * &raquo; Mensagem<br>
     * &raquo; RemetenteNome<br>
     * &raquo; RemetenteEmail<br>
     * &raquo; DestinoNome<br>
     * &raquo; DestinoEmail
     * </i>
     */
    public function Enviar(array $Data) {
        $this->Data = $Data;
        $this->Clear();

        if (in_array('', $this->Data)):
            $this->Error = ['Erro ao enviar mensagem: Para enviar esse e-mail. Preencha os campos requisitados.', WS_ALERT];
            $this->Result = false;
        elseif (!Check::Email($this->Data['RemetenteEmail'])):
            $this->Error = ['Erro ao enviar mensagem: O e-mail que você informou não tem um formato válido. Informe um e-mail válido.', WS_ALERT];
            $this->Result = false;
        else:
            $this->setMail();
            $this->Config();
            $this->sendMail();
        endif;
    }

    /**
     * <b>Verificar Envio:</b> Executando um getResult é possível verificar se foi ou não efetuado 
     * o envio do e-mail. Para mensagens execute o getError();
     * @return BOOL $Result = TRUE or FALSE
     */
    public function getResult() {
        return $this->Result;
    }

    /**
     * <b>Obter Erro:</b> Retorna um array associativo com o erro e o tipo de erro.
     * @return ARRAY $Error = Array associatico com o erro
     */
    public function getError() {
        return $this->Error;
    }

    /*
     * ***************************************
     * **********  PRIVATE METHODS  **********
     * ***************************************
     */

    //Limpa código e espaços!
    private function Clear() {
        array_map('strip_tags', $this->Data);
        array_map('trim', $this->Data);
    }

    //Recupera e separa os atributos pelo Array Data.
    private function setMail() {
        $this->Assunto = $this->Data['Assunto'];
        $this->Mensagem = $this->Data['Mensagem'];
        $this->RemetenteNome = $this->Data['RemetenteNome'];
        $this->RemetenteEmail = $this->Data['RemetenteEmail'];
        $this->DestinoNome = $this->Data['DestinoNome'];
        $this->DestinoEmail = $this->Data['DestinoEmail'];

        $this->Data = null;
        $this->setMsg();
    }

    //Formatar ou Personalizar a Mensagem!
    private function setMsg() {
        $this->Mensagem = "{$this->Mensagem}<hr><small>Recebida em: " . date('d/m/Y H:i') . "</small>";
    }

    //Configura o PHPMailer e valida o e-mail!
    private function Config() {
        //SMTP AUTH
        $this->Mail->IsSMTP();
        $this->Mail->SMTPAuth = true;
        $this->Mail->IsHTML(true);

        //REMETENTE E RETORNO
        $this->Mail->From = MAILUSER;
        $this->Mail->FromName = $this->RemetenteNome;
        $this->Mail->AddReplyTo($this->RemetenteEmail, $this->RemetenteNome);

        //ASSUNTO, MENSAGEM E DESTINO
        $this->Mail->Subject = $this->Assunto;
        $this->Mail->Body = $this->Mensagem;
        $this->Mail->AddAddress($this->DestinoEmail, $this->DestinoNome);
        $this->Mail->addCC($this->RemetenteEmail, $this->RemetenteNome);
    }

    //Envia o e-mail!
    private function sendMail() {
        if ($this->Mail->Send()):
            $this->Error = ['Obrigado por entrar em contato: Recebemos sua mensagem e estaremos respondendo em breve!', WS_ACCEPT];
            $this->Result = true;
        else:
            $this->Error = ["Erro ao enviar mensagem: Entre em contato com o admin. ( {$this->Mail->ErrorInfo} )", WS_ERROR];
            $this->Result = false;
        endif;
    }
}

In contact for I use this

<?php
                $Contato = filter_input_array(INPUT_POST, FILTER_DEFAULT);
                if ($Contato && $Contato['SendFormContato']):
                    unset($Contato['SendFormContato']);

                    $Contato['Assunto'] = 'msg via site';
                    $Contato['DestinoNome'] = 'Geral - BR Zeladoria Patrimonial';
                    $Contato['DestinoEmail'] = 'geral@brzeladoria.com.br' && $Contato['RemetenteEmail'];

                    $SendMail = new Email;
                    $SendMail->Enviar($Contato);

                    if ($SendMail->getError()):
                        WSErro($SendMail->getError()[0], $SendMail->getError()[1]);
                    endif;

                endif;
                ?>

May be I have samething wrong that I can’t see

@Dormilich any idea about this error, I’m trying to solve is already to much time, or maybe I need to change my class method, create another one, or something like this…

what error?

If you are still having problems with the “no such file or directory” error, my guess is that the path is incorrect.

require ('../Library/PHPMailer/class.phpmailer.php'); 

Does not look like

Before continuing, please be sure that PHPMailer is installed correctly. If you feel uncertain, please read the installion instructions that accompany the package. If you’re still not sure, you can verify that you’ve installed PHPMailer correctly with this little script:

<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer; 

In other words, instead of trying to debug the more complex script, I think you will have a better go if you step back, make sure everything is OK, and work your way up to the more complex script.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.