Sending PHP mail () to spam GMAIL

I know this problem has been addressed several times here. I tried following the guidelines for setting the correct headers, I still encounter problems with my messages going to the spam filter in Gmail.

If anyone can take a look at what I have tried, I would really appreciate it. Below is the code without added headers, as described here: http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/

Thanks in advance.

define("WEBMASTER_EMAIL", 'myName@mydomain.com');
if($post)
{
    $name    = stripslashes($_POST['name']);
    $email   = trim($_POST['email']);
    $subject = trim($_POST['subject']);
    $message = stripslashes($_POST['message']);

    $error = '';

    // Check name
    if(!$name)
        $error .= 'Name required! ';

    // Check email
    if(!$email)
        $error .= 'E-mail required! ';

    if($email && !ValidateEmail($email))
        $error .= 'E-mail address is not valid! ';

    // Check message
    if(!$message)
        $error .= "Please enter your message!";

    if(!$error)
    {

        $mail = mail(WEBMASTER_EMAIL, $subject, $message,
            "From: ".$name." <".$email.">\r\n"
            ."Reply-To: ".$email."\r\n"
            ."X-Mailer: PHP/" . phpversion());

        if($mail)
            echo 'OK';
    }
    else
        echo '<div class="errormsg">'.$error.'</div>';
}
+5
source share
3 answers

Use this code :

 $to = Email;
 $subject = subject ;
 $body = "<div> hi hi .. </div>";

    $headers = 'From: YourLogoName info@domain.com' . "\r\n" ;
    $headers .='Reply-To: '. $to . "\r\n" ;
    $headers .='X-Mailer: PHP/' . phpversion();
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";   
if(mail($to, $subject, $body,$headers)) {
  echo('<br>'."Email Sent ;D ".'</br>');
  } 
  else 
  {
  echo("<p>Email Message delivery failed...</p>");
  }
+9
source

I think this is your problem:

 "From: ".$name." <".$email.">\r\n"

gmail, hotmail , "From: otherdomain.com", "mail.yourdomain.com" - .

 "From: YourWebsiteName <noreply@yourwebsite.com>\r\n"
."Reply-To: ".$name." <".$email.">\r\n"

.

, - google "email header injection php"!

+4

Google -, , . , Google , , php mail() - gmail. .

google "":

"Why is this message in spam? We found that a lot of messages from home.pl are spam. More details ...

0
source

All Articles