shilna mk
shilna mk

Reputation: 9

Mail go to spam instead of inbox and some errors in header part of mail using PHP

i am trying for send mail using php.My mail go to spam and some other errors are also in mail.

My header code is

$header_mail="select content from mail_header where id='1'";
$header_mail2=mysql_query($header_mail);
$fet=mysql_fetch_array($header_mail2);

$content= htmlentities($fet['content']);

$Headers = "From:$content\r\n" . 
"Reply-To:$content\r\n" . 
"Content-type: text/html; charset=UTF-8 \r\n"; 
$Headers.= "MIME-version: 1.0\n";
$Headers.= "Content-type: text/html; charset= iso-8859-1\n";

data in $content is zamisoft<zamisoft.com> but i got the mail as with

from:    Zamisoft&lt

reply-to: Zamisoft&lt, [email protected]&gt

I got the these message in mail

"Be careful with this message. Many people marked similar messages as phishing scams, so this might contain unsafe content. Learn more "

Mail is going to spam and errors are in header section part of mail.

Any body help me for solve these issue?

Upvotes: 0

Views: 946

Answers (2)

radiopassive
radiopassive

Reputation: 566

remove the htmlentities() from $content= htmlentities($fet['content']); and then try!

Since you are already setting the Content Type and Character Encoding, the contents of the array $fet['content'] will be read properly by the browsers!

htmlentities() converts the html tags to htmlentities (eg. < to &lt;) which is what you are facing!!

Try it and let us know if the problem persists

Remove the line "Content-type: text/html; charset=UTF-8 \r\n"; as you have defined the header in the last line of header.

Add $Headers .= 'X-Mailer: PHP/' . phpversion()."\r\n"; at the last line of your code.

It tells which version of php is being used!

Also the email address should be a valid one as well!!

Upvotes: 0

Mohammad Faisal
Mohammad Faisal

Reputation: 5959

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

Upvotes: 1

Related Questions