Error: You must provide at least one email address

0

Colleagues.

I have a site where I have 02 forms. One for the traditional Contact Us and the other for sending resume. I'm using PHPMailer. No Contact Us is working properly, however in the other resume submission form, the following error appears: You must provide at least one email address.

The following is the code below:

  include("includes/class.phpmailer.php");
        $mail = new PHPMailer();
        $mail->From = "[email protected]";
        $mail->FromName = "Currículo";
        $mail->AddAddress("[email protected]");
        $mail->IsHTML(true);
        $mail->AddAttachment($curriculo['tmp_name'],$curriculo['name']);
        $data = date("d/m/Y");
        $hora = date("H:i");
        $mensagemHTML = "mensagem";
  $mail->Subject = "Vaga enviada pelo site";
        $mail->Body = $mensagemHTML;

        $mail->ClearAllRecipients();
        $mail->ClearAttachments();

       if($mail->Send()){
           $mensagem = 'Seu curriculo foi enviada com sucesso!';
       }else{
           $mensagem = "Erro ao enviar. Se o erro persistir, entre em contato                 conosco!";
       }

The directory is correct, just like the email. Would anyone know why this error occurred?

    
asked by anonymous 15.11.2016 / 11:48

2 answers

1

I think the problem is:

    /// aqui você adiciona um recipient
    $mail->AddAddress("[email protected]");
    $mail->IsHTML(true);
    $mail->AddAttachment($curriculo['tmp_name'],$curriculo['name']);
    $data = date("d/m/Y");
    $hora = date("H:i");
    $mensagemHTML = "mensagem";
    $mail->Subject = "Vaga enviada pelo site";
    $mail->Body = $mensagemHTML;

    // aqui você apaga todos <<<<<<<<
    $mail->ClearAllRecipients();

Try to comment on this line above.

PS: the text is wrong. "Your resume has been successfully submitted."

    
15.11.2016 / 14:53
0

According to the error message you are not assigning any value in the $ mail-> AddAddress () property, despite the code you posted being.

Before executing the Send () method of a var_dump in $ mail to make sure you actually assigned an address.

var_dump($mail);
    if($mail->Send()){
    
15.11.2016 / 11:59