O
O
Olga2018-10-01 19:06:55
PHP
Olga, 2018-10-01 19:06:55

How to set PHPMailer to display the page title in the email header?

Good evening! The email settings themselves are as follows

$mail->isHTML(true); 
$mail->Subject = “Новая заявка на консультацию”; // Заголовок письма
$mail->Body = “Имя $name . Телефон $phone . Почта $email”; // Текст письма
// Результат
if(!$mail->send()) {
 echo ‘Message could not be sent.’;
 echo ‘Mailer Error: ‘ . $mail->ErrorInfo;
} else {
 echo ‘ok’;
}

And I can't figure out how you can set the title from the page so that you can determine where the application came from
. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Karavaev, 2018-10-02
@Quieteroks

<form>
    <input type="hidden" name="page" value="Главная страница">
    <...>
</form>

...
$mail->Subject = “Новая заявка на консультацию: ” . $_POST['page']; // Заголовок письма
...

This is the easiest way and you need to understand that any garbage can also be slipped there. BUT! You can look at the request route. If the request comes from another page, there is also referrer data by which the page can be determined. And by url already build the desired subtitle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question