Error sending email: server Answer: 550 5.7.1 Must Authenticate

Asked

Viewed 667 times

1

I’m trying to use the function mail() of However, the following warning appears when I run the script:

" Warning: mail() [Function.mail]: SMTP server Answer: 550 5.7.1 Must Authenticate!"

How do I set this up?

Follows the code:

$message = "Blablablablablablabla";

// In case any of our lines are larger than 70 characters, we should use wordwrap()

$message = wordwrap($message, 70);

// Send

mail('[email protected]', 'Solicitação de Cadastro de Fornecedor de Serviço - Numero - 111 - Controladoria - Marco Projetos e Construções', $message);
  • could put the code in the question, so we understand better?

  • Code posted.

3 answers

2


To prevent email abuse, better known as SPAM, many servers require the client to be authenticated and legitimate.

The function mail() cannot perform this authentication, so it is necessary to use another library that supports SMTP authentication. (PEAR Mail, phpmailer, Swift Mailer, etc)

If you have an interest, recommend that great tutorial to use Phpmailer.

Source Fonte2

  • I downloaded the Phpmailer class and tried to run, but it gives an error warning in the SMTP class... If I am not mistaken, it says that SMTP does not exist or does not work :(

  • Which SMTP server are you using? It is the one provided by the server?

  • From earth @Lucas. smtp.poa.terra.com.br and the same requires authentication.

  • I managed to run phpmailer... It just doesn’t seem to be getting to the recipient! I was pointing the riquire(phpmailer.php) the wrong way. Thanks anyway

0

Some servers do not allow the field from email is omitted. It is configured as the fourth argument of the mail function.

Configure it as follows:

$headers = 'From: [email protected]' . PHP_EOL;
mail('[email protected]', 'titulo', $message, $headers);

0

You have to build and send the headers of your email:

    $headers  = 'From: [email protected]'."\r\n";
    $headers .= 'Reply-To: [email protected]'."\r\n";
    $headers .= 'MIME-Version: 1.0'."\n";
    $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";

    if(mail('[email protected]', 'Solicitação de Cadastro de Fornecedor de Serviço - Numero - 111 - Controladoria - Marco Projetos e Construções', $message, $headers)) 
        echo "Email enviado";
    else 
        echo "Ocorreu um erro no envio do email!";
  • I am receiving the same warning: "Warning: mail() [<a href='Function.mail'>Function.mail</a>]: SMTP server Answer: 550 5.7.1 Must Authenticate!"

  • error appears on your browser? console is developing locally or on a server?

  • 1

    The warning appears on the screen. I’m developing local.

  • to develop email applications locally you need to install and/or configure other components to overcome authentication restrictions. I advise you to try uploading your code to a server and test the email features there.

  • All right @CIRCLE, I’ll do it.

Browser other questions tagged

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