0

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);
}
}
2
Contributors
2
Replies
30
Views
2 Years
Discussion Span
Last Post by cristian.stilpeanu.1_1
0

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:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.