-->

How to avoid my mails sent from PHP mail() being m

2020-03-03 04:56发布

问题:

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, $message, $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.

回答1:

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.



回答2:

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.