Error sending email: server response: 550 5.7.1 Must Authenticate

1

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

  

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

How do I set this up?

Follow 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);
    
asked by anonymous 06.11.2014 / 14:11

3 answers

2

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

The mail() function can not 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, I recommend this great tutorial to use PHPMailer.

Fountain Font2

    
06.11.2014 / 14:35
0

Some servers do not allow the from field of the email to be 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);
    
06.11.2014 / 14:30
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!";
    
06.11.2014 / 14:30