hello, after I fill the contact form, I get the message that was sent successfully, but my email receive error:

A message that you sent was rejected by the local scanning code that
checks incoming messages on this system. The following error was given:

Erorare reference : This email was looking for a about is sent without
authentication

------ This is a copy of your message, including all the headers. ------

mail.php

<?php

include 'functions.php';

if (!empty($_POST)){

  $data['success'] = true;
  $_POST  = multiDimensionalArrayMap('cleanEvilTags', $_POST);
  $_POST  = multiDimensionalArrayMap('cleanData', $_POST);

  //your email adress 
  $emailTo ="yourmail@yoursite.com"; //"yourmail@yoursite.com";

  //from email adress
  $emailFrom ="contact@yoursite.com"; //"contact@yoursite.com";

  //email subject
  $emailSubject = "Mail from Porta";

  $name = $_POST["name"];
  $email = $_POST["email"];
  $comment = $_POST["comment"];
  if($name == "")
   $data['success'] = false;

 if (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) 
   $data['success'] = false;


 if($comment == "")
   $data['success'] = false;

 if($data['success'] == true){

  $message = "NAME: $name<br>
  EMAIL: $email<br>
  COMMENT: $comment";


  $headers = "MIME-Version: 1.0" . "\r\n"; 
  $headers .= "Content-type:text/html; charset=utf-8" . "\r\n"; 
  $headers .= "From: <$emailFrom>" . "\r\n";
  mail($emailTo, $emailSubject, $message, $headers);

  $data['success'] = true;
  echo json_encode($data);
}
}

Dani AI

Generated

Short diagnosis and next steps (follow-up to ): the bounce "sent without authentication" means the mail was rejected by the receiving/relay system because it arrived without proper authentication (SMTP login or valid sender authentication like SPF/DKIM/DMARC). PHP’s mail() hands messages to the server MTA (sendmail/Postfix/Exim), and many hosts either block unauthenticated relaying or treat messages whose envelope sender/headers don’t match the domain as unauthenticated. Using an SMTP client that authenticates to your mail provider avoids that behavior. (github.com)

Practical fix — use an SMTP library (recommended): replace mail() with a library such as PHPMailer or the Symfony Mailer so you can authenticate (username/password or API), use TLS, and set proper envelope headers. Minimal PHPMailer pattern (replace placeholders with your values):

use PHPMailer\PHPMailer\PHPMailer;
require 'vendor/autoload.php';

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->Username = 'smtp-user';
$mail->Password = 'smtp-pass';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;

$mail->setFrom('contact@yourdomain.com','Site contact');
$mail->addAddress('you@yourdomain.com');
$mail->isHTML(true);
$mail->Subject = 'Contact form';
$mail->Body = $htmlMessage;

$mail->send();

PHPMailer docs and examples: PHPMailer on GitHub. If you prefer framework tooling, Symfony Mailer replaces SwiftMailer and supports provider bridges. (github.com)

Short-term / troubleshooting tips: if you must keep mail() temporarily, set the envelope sender so the MTA sees a matching bounce address (fifth parameter, e.g. mail($to,$subject,$message,$headers,'-fcontact@yourdomain.com')) — this can help, but hosts that require SMTP auth will still block sending. Check server mail logs and the full bounce headers for the exact rejection. Also verify your domain’s SPF/DKIM/DMARC records so other sites accept mail from your domain; these records are a common cause of “unauthenticated” rejections. See guidance on SPF/DKIM/DMARC setup. (knowledge.workspace.google.com)

Quick checklist: (1) switch to authenticated SMTP with a library, (2) ensure From and envelope sender use your domain, (3) publish correct SPF and DKIM and start with a relaxed DMARC while testing, (4) read the mail logs for the exact rejection string and contact host support if the server enforces outbound authentication.

Recommended Answers

All 2 Replies

Erorare reference : This email was looking for a about is sent without authentication

It means that the SMTP server used to send the email requires the authentication for the email defined here:

$emailFrom ="contact@yoursite.com";

i.e. it requires the password. With mail() you can do this only by editing the php.ini file as explained here:

A better solution is to use libraries like PHPMailer or SwiftMailer:

Otherwise you have to use PHP sockets, which is what the above libraries do. A basic script would look like in this example:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.