Wednesday 15 May 2013

Php mail tagged as Spam in Gmail Issue fixed

Issue

When I send mail using PHP mail() function,the mail is sent to the Spam folder in GMail.

Solution

You can fix this issue by using the fifth parameter in the mail function to build the header with a valid From address.

PHP Code

<?php 
 
$to 
'you@gmail.com';


$from 'you@yourserver.com';


$message 'Hello';

$subject 'Test Mail';


mail($to$message$subject"From: $from""-f$from");


?> 
 

No comments:

Post a Comment