E
E
EVG822020-12-17 10:25:30
PHP
EVG82, 2020-12-17 10:25:30

How to set up a From transfer?

Good!
Letters go to spam in gmail.com The
provider writes that the From header is not correctly transmitted
verbatim:

2020-12-14T15:16:01.469562+03:00 srv172-h-st postfix/qmgr[9010]: 899E25C007D: from=<[email protected]>, size=15785, nrcpt=1 (queue active)
2020-12-14T15:16:01.525530+03:00 srv172-h-st postfix/error[27100]: 899E25C007D: to=<[email protected]>, relay=none, delay=1158, delays=1158/0/0/0.06, dsn=4.4.2, status=deferred (delivery temporarily suspended: lost connection with gmail-smtp-in.l.google.com[2a00:1450:4010:c08::1a] while sending DATA command)
2020-12-14T15:36:01.420762+03:00 srv172-h-st postfix/qmgr[9010]: 899E25C007D: from=<[email protected]>, size=15785, nrcpt=1 (queue active)
2020-12-14T15:36:04.526858+03:00 srv172-h-st postfix/smtp[26952]: 899E25C007D: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[2a00:1450:4010:c08::1b]:25, delay=2361, delays=2358/0.01/0.13/3, dsn=2.0.0, status=sent (250 2.0.0 OK 1607949364 y199si7553398lff.558 - gsmtp)
2020-12-14T15:36:04.527789+03:00 srv172-h-st postfix/qmgr[9010]: 899E25C007D: removed
У Вас скрипт не передает from корректно, поэтому подставляется серверное значение from=<[email protected]>
Нужно сделать корректно from.


And here is the script

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['name'])) {$name = $_POST['name'];}
    if (isset($_POST['phone'])) {$phone = $_POST['phone'];}
    if (isset($_POST['email'])) {$email = $_POST['email'];}
    if (isset($_POST['city'])) {$city = $_POST['city'];}
    if (isset($_POST['date'])) {$date = $_POST['date'];}
    if (isset($_POST['formData'])) {$formData = $_POST['formData'];}

    $to = "[email protected]"; /*Укажите адрес, га который должно приходить письмо*/
    $sendfrom   = "[email protected]"; /*Укажите адрес, с которого будет приходить письмо, можно не настоящий, нужно для формирования заголовка письма*/
    $headers  = "From: " . strip_tags($sendfrom) . "\r\n";
    $headers .= "Reply-To: ". strip_tags($sendfrom) . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html;charset=utf-8 \r\n";
    $subject = "Новая заявка с лендинга";
    $message = "$formData<br> <b>Имя пославшего:</b> $name <br><b>Телефон:</b> $phone <br><b>E-mail:</b> $email<br><b>Город:</b> $city <br><b>Дата рождения:</b> $date";
    $send = mail ($to, $subject, $message, $headers);
    if ($send == 'true')
    {
    echo '<center><p class="success">Спасибо за отправку вашего сообщения!</p></center>';
    }
    else 
    {
    echo '<center><p class="fail"><b>Ошибка. Сообщение не отправлено!</b></p></center>';
    }
} else {
    http_response_code(403);
    echo "Попробуйте еще раз";
}
?>


I can't figure out what to write?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-12-17
@galaxy

It is unlikely that the problem is in From, most likely, as usual, in setting up the mail server, SPF / DMARC.
And generally speaking, you can’t do this with the mail() function :

$subject = "Новая заявка с лендинга";
...
$send = mail ($to, $subject, $message, $headers);

J
Jupiter Max, 2020-12-17
@vardoLP

maybe there is?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question