H
H
Hazrat Hajikerimov2014-07-11 16:39:28
PHP
Hazrat Hajikerimov, 2014-07-11 16:39:28

Why do messages sent via mail() end up in spam?

Many times, on different projects, I noticed one thing that when sending an email message through the php mail() function, it will definitely end up in SPAM, with Google, Mail.RU, Rambler. What is it connected with? Maybe some additional headers to specify? piece of code below:

$to = $res['email'];
            $subject =  "Официальный ответ";
            $message = '<html>
                            <head>
                                <title>Официальный ответ</title>
                            </head>
                            <body>
                                <span>
                                    <b>Текст вашего обращения:</b><br>
                                </span>
                                <hr>
                                <h4>Официальный ответ</h4>
                            </body>
                        </html>';
            $headers  = "Content-type: text/html; charset=utf-8 \r\n";
            $headers .= "От:  [email protected]\r\n";
            $headers .= "Bcc: [email protected]\r\n";
            mail($to, $subject, $message, $headers);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Calc, 2014-07-11
@hazratgs

mail uses sendmail or postfix on your machine.
If the machine ip does not have a ptr (DNS ptr, writeback, etc.) record, then the message will 100% be spammed, and the machine (ip) will be in the spam list
Solution here
Where can I find smtp not a local server for a developer?

F
Fyodor Dostoyevsky, 2014-07-11
@frops

You also need to dig towards the DKIM signature (DomainKeys Identified Mail). You can read a little about her here .

S
Sergey, 2017-03-23
@cupok

Personally, it was $headers = "Content-type: text/html; charset=utf-8 \r\n"; removed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question