Phpmailer error while sending

Asked

Viewed 125 times

0

Opa, I am using a function to send mail with phpmailer, follows function

function SendMail($acessa_arquivo, $email_destinatario, $nome_destinatario, $assunto, $mensagem, $link)
{

    require_once("_files_itens/PHPMailer/PHPMailerAutoload.php");




    $mail = new PHPMailer;
    //$mail->SMTPDebug = 3; 

    $mail->IsMAIL();

    $mail->Host = 'mail.site.com.br'; 
    $mail->SMTPAuth = true; 
    $mail->Username = '[email protected]';
    $mail->Password = '**********';      
    $mail->Port = 587; 
    $mail->setFrom('[email protected]', 'site');
    $mail->addAddress($email_destinatario, $nome_destinatario);
    $mail->isHTML(true);  
    $mail->Subject = $assunto;
    $mail->Body    = $mensagem;
    $mail->AltBody = $mensagem;


        if(!$mail->send()) {
            echo 'OOOO.';
            echo 'Mailer Error: ' . $mail->ErrorInfo;
        } else {
            echo 'Mensagem Enviada';
        }

}

The point is that this function works perfectly, but when I try to reuse it on another page, I’m getting a phpmailer error, which I couldn’t identify.

Error: Mailer Error: Could not instantiate mail function.

The recipient email is correct, the subject does not exceed 20 characters in letters.

  • You’ve already solved your problem?

  • No buddy, I focused on another project, I left this with email a little aside.

  • in setFrom try to add a third parameter like 0. Ex: $mail->setFrom($email, $name, 0);

  • Another possible solution in the $mail->addAddress() function; leave only one parameter: email

  • Just after instantiating the $mail variable as Phpmailer, assign the following parameter: $mail->Issmtp(); instead of $mail->Ismail()

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.