A
A
Anton2017-12-25 18:49:07
JavaScript
Anton, 2017-12-25 18:49:07

How to fix cracks in outgoing emails?

AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("OnAfterArticleAdd", "OnAfterIBlockElementAddHandlerLast"));
class OnAfterArticleAdd {
   function OnAfterIBlockElementAddHandlerLast(&$arFields) {
      if ($arFields["IBLOCK_ID"] == 26 && $arFields["RESULT"]>0) {
$message .= 'Свойство 1: '.$arFields['PROPERTY_VALUES']['FIO'];
         mail('[email protected]', 'Добавлен отзыв на сайт', $message, $headers);
      }
   }
}

At the output we have:
Свойство 1: Антон
i.e. the first part is norm-coded, but the second part (the one with $arFields['PROPERTY_VALUES']['FIO']) is not.
How to fix?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Roman, 2019-10-17
@AndrewRusinas

I think the problem is here:

fs.writeFile(fullPath, base64Image, { encoding: 'base64' }, err => {
            if (err) return res.status(500).send(`Ошибка сохранения файла: ${err}`)
            else return
        });

because after this piece of code, without waiting for the result, the following code is executed. Thus, it is possible that send in this piece of code will be executed after send in the following code,
try replacing this code with:
const promise = new Promise(resolve, reject)=>{
   fs.writeFile(fullPath, base64Image, { encoding: 'base64' }, err => {
      if (!err) return resolve(true);
      
      res.status(500).send(`Ошибка сохранения файла: ${err}`)
      return reject(false);
   });
});
const isWrite = await promise;
if(!isWrite) return;

A
Anton, 2017-12-25
@sHinE

php.net/manual/ru/function.mb-convert-encoding.php
something like this, play around with the second parameter of the function, perhaps a different encoding will be needed there.

E
Exploding, 2017-12-25
@Exploding

So to speak, "temporarily rewound with tape":
Well, or just make sure that the array "comes" not in 1251, but immediately in utf8

R
Roman Gritsuk, 2017-12-25
@winer

There is already a built-in functionality for working with mail events. Use it.
Link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question