Good day.

I wrote my SMTP server, it works, but sometimes messages come to it in the format:

Content-Transfer-Encoding: 8bit

Here is the message text itself:

Received: ************************************************ **** ************************************** Sat, 4 Jun 2016 10:48: 34 +0300 (EEST) Date: Sat, 4 Jun 2016 10:48:34 +0300 (EEST) From: from@mail.ru To: to@mail.ru Message-ID: 1354354354354354374354343438434384348448 Subject: MIME-Version: 1.0 Content -Type: text / plain; charset = Windows-1251 Content-Transfer-Encoding: 8bit X-Mailer: ColdFusion 9 Application Server X-MCServiceID: 22 X-SMSPriority: Low

Sample Message ?????? ?????? ??????? ????????? ? - (?????????).

I get the message text through the socket and translate it into text:

Encoding.ASCII.GetString(b) 

I read that 8bit - Это значение указывает, что данные в теле сообщения содержат знаки, которых нет в кодировке US-ASCII

Maybe this is not a problem with SMTP? Or if he has, how can the question be solved?

Thank.

  • Well, Encoding.ASCII doesn't look like much. You should not guess the encoding (especially since the assumption that it is ASCII is clearly unrealistic: letters may well be, for example, in Russian). Disassemble the letter header (not regular, please), find the correct encoding there (in your case CP1252), and decode the message correctly. - VladD
  • I get an array of bytes from the socket, in order to read the header, I need to somehow convert it into text. Those. You will again convert the byte array in CP1252, yes? - Leonard Bertone
  • In theory, yes. You save the bytes, convert to ASCII, parse until you find the real encoding, then convert the same source bytes again. Although it is better, of course, to look into the RFC, to be sure. - VladD
  • 3
    Or perhaps the header has a separate encoding, and it needs to be processed separately. Take a look at the RFC, and the truth. - VladD
  • 3
    Here I saw the answer. stackoverflow.com/questions/25710599/… Problem like yours - Senior Pomidor

0