0

I am having a problem with my code when my website send register email to user, it goes into spam folder. This is the picture of email that got to spam.

enter image description here It also says that via gator4168.hostgator.com which what I don't want. This is the code I am using.

function register_user($register_data){
        array_walk($register_data, 'array_sanitize');
        $register_data['password'] = md5($register_data['password']);

        $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
        $data = '\'' . implode('\', \'', $register_data) . '\'';
        $headers ="From:<$from>\n";
        $headers.="MIME-Version: 1.0\n";
        $headers.="Content-type: text/html; charset=iso 8859-1";
        mysql_query("INSERT INTO `users` ($fields) VALUES ($data)");
        email($register_data['email'], 'Camdrivers Member Activating Request', "Dear " . $register_data['first_name'] . ",\n\nYou have just registed in our website, Camdrivers.asia to be one of our publisher members. In order to join us, we need first to identify whether your contact email is correct or not. \n\nYou need to activate your account before you can use it. Click the link below to acctivate now:\n\nhttp://camdrivers.asia/activate?email=" . $register_data['email'] . "&email_code=" . $register_data['email_code'] . "\n\n- CamDrivers\n\n- Tel: (855)97 77 56 098 / (855)96 90 96 091\n\n- Location: Siem Reap, Cambodia",$headers);
    }

Can you help me solve the problem to get all my email to be sent to inbox not spam?

Thanks

  • 1
    Its the problem with SMTP server, not PHP's `mail` function. – Thamilhan Oct 04 '17 at 15:40
  • How can you help me? Please – Sreng Pagna Oct 04 '17 at 15:42
  • MD5 is considered broken for security purposes and is not sufficient for password hashing. Use [`password_hash()`](http://us3.php.net/manual/en/function.password-hash.php) and [`password_verify()`](http://us3.php.net/manual/en/function.password-verify.php) instead. If you're using a version of PHP prior to 5.5, you can use [this compatibility pack](https://github.com/ircmaxell/password_compat). – Alex Howansky Oct 04 '17 at 18:21

1 Answers1

3

You can influence, but not control this. It is up to each individual person to configure how their email is sorted and therefore marked as Junk or not.

There are some things you can do however, like:

  • sending plain text email bodies
  • using a trusted SMTP server
  • enabling SPF for your domain
  • DKIM signing your emails

Explaining everything here seems superfluous, there are many many guides on the WWW helping you out with this.

My advice is to register a dummy user with an email address from Mail Tester and start from there.

Good luck!

Bart Van Loon
  • 1,430
  • 8
  • 18