0

please refer the following code.in there am sending username and password.email has sent to the gmail.but it is in spam folder.it happens only in gmail.

Here is my code

$to = $email;
$subject = ' Web Site| login Details'; // Give the email a subject
$message = '
        Thanks for signing up!
        Your account has been created, you can login with the following credentials.

        ------------------------
        Username: '.$uname.'
        Password: '.$upass.'

        Web Builder login: '.$ulink.'
        ------------------------ ';

$headers .= 'From:noreply@ggg.eee.net' . "\r\n";
$headers .= 'Bcc: kae@ggg.eee.net' ."\r\n";
$headers .= 'Bcc: thi@ggg.eee.net' ."\r\n";
mail($to, $subject, $message, $headers);
mpalencia
  • 5,481
  • 4
  • 45
  • 59
colombo
  • 520
  • 2
  • 9
  • 24

3 Answers3

0

There are many reasons why email providers mark your messages as spam. Sometimes it has to do with the way your server and DNS are configured or other times it may be the content of your message. I would recommend using this tool to help pinpoint the weak spots of your email messages to help you get through most spam filters

Mail-Tester.com

blazerunner44
  • 657
  • 8
  • 19
0

Use this code may be it work properly

$to = Email;
  $subject = ' Web Site| login Details'; // Give the email a subject
    $message = '

        Thanks for signing up!
        Your account has been created, you can login with the following credentials.

        ------------------------
        Username: '.$uname.'
        Password: '.$upass.'

        Web Builder login: '.$ulink.'
        ------------------------ ';

    $headers = 'From: noreply@ggg.eee.net' . "\r\n" ;
    $headers .='Reply-To: '. $to . "\r\n" ;
    $headers .= 'Bcc: kae@ggg.eee.net' ."\r\n";
    $headers .= 'Bcc: thi@ggg.eee.net' ."\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,  $message ,$headers)) {
  echo('<br>'."Email Sent ;D ".'</br>');
  } 
  else 
  {
  echo("<p>Email Message delivery failed...</p>");
  }
Sandeep Vishwakarma
  • 566
  • 1
  • 5
  • 17
0

I have found the soution of this problem:
Solution-1: Use double quotes to headers.

Solution-2: The problem is simple that the PHP-Mail function is not using a well configured SMTP Server.

Nowadays Email-Clients and Servers perform massive checks on the emails sending server, like Reverse-DNS-Lookups, Graylisting and whatevs. All this tests will fail with the php mail() function. If you are using a dynamic ip, its even worse.

Use the PHPMailer-Class and configure it to use smtp-auth along with a well configured, dedicated SMTP Server (either a local one, or a remote one) and your problems are gone.

https://github.com/PHPMailer/PHPMailer

Source of solution

Community
  • 1
  • 1
Kabir Hossain
  • 2,865
  • 1
  • 28
  • 34