How to avoid my mails sent from PHP mail() being marked as spam?
I'm using the following to send registration e-mails:
$subject = 'subject is here';
$message_raw = 'e-mail text';
$message = base64_encode($message_raw);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\r\n";
$headers .= 'From: papa.sk <register@papa.sk>' . "\r\n";
$sendit = mail($to, $subject, $mess开发者_如何学运维age, $headers);
For some people the e-mails are put into the spam folder (in gmail too).
In /etc/postfix/main.cf I have this:
myorigin = /etc/mailname
smtpd_banner = papa1.vps.websupport.sk ESMTP
Not sure whether I should change the above.
you may need a reverse dns record for your server.
many mail servers considers that mails sent from a host are spam if the hostname cannot be looked up. that is nslookup papa.sk
should return an ip address, and nslookup <ip address>
should return papa.sk.
The php mail()
function has nothing to-do with your emails being marked as spam.
That an email is being marked as spam happens on the other end. You can not influence the process much with mail()
- as it's the other end.
There can be thousand of reasons why an email is being marked as spam, and as long as you don't know the concrete reason why your email is being marked as spam, you can do nothing against that.
There is a whole industry which makes a living of that btw.
精彩评论