M
M
MaxGoodWork2021-02-20 16:54:07
PHP
MaxGoodWork, 2021-02-20 16:54:07

How to add variable value to multipart email?

All for nothing, a problem arose - I needed to add a text version of the letter to the html version, converted it to multipart, but the letter stopped being sent. I began to try to figure it out, but when I deleted the values ​​of the $_post array, the letter was successfully sent. (although there are no such problems outside of multipart) Or maybe the problem is that I use string concatenation (I can’t say because of my little experience in this matter). In any case, the problem is on this side, please help me figure it out:

$headers = "From: *
               MIME-Version: 1.0
               Content-Type: multipart/alternative; charset=UTF-8; boundary=sep
         --sep
         Content-Type: text/plain
         Алексей, начинайте работу!
         С ним можно связаться через " . $_POST['reqtype'] .
         "\n\rКонтакт заказчика: " . $_POST['mail'] .
         "\n\rЕго имя: " . $_POST['uname'] .
         "Его запрос:\n\r" . $_POST['ureq'] .
         "\n\r--sep
         Content-Type: text/html
         <html><body>
         Алексей, начинайте работу!<br>С ним можно связаться через " . $_POST['reqtype'] . "<br>Контакт заказчика: " . $_POST['umail'] . ";<br>Его имя: " . $_POST['uname'] . ";<br>Его заппрос:<br>" . $_POST['ureq'] .
         "</body></html>
         --sep--
         ";
  $subject = "Алексей, новая заявка от заказчика на сайте *!";
  if(strlen($text) > 10000) return;
  mail("***",
     "=?UTF-8?B?".base64_encode($subject)."?=",
     "",
     $headers);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Dubrovin, 2021-02-20
@MaxGoodWork

Not sure if mail() can be used this way, but at a minimum: you don't have a blank line after the headers in both the main and both text. The line separator must be CRLF, \n\r is most likely LFCR or CRLFCR. And this in this case does not affect, but the charset must be specified for the text-part, and not for the multi-part.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question