The email is going to spam. How I tweak the code so that email would sent into Inbox not into SPAM. Please help....

There is no quick fix but read this. You need to understand how the SPAM filters work and avoid the things that SPAM filters look for.

Try adding "From:" in the headers field while sending email

$headers = "From: abc@xyz.com\r\nReply-To: efg@xyz.com";
$mail_sent = @mail( $to, $subject, $message, $headers );

This should be a dns issue. And I think it's the SPF record.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.