TIdSMTP problems lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- dpap · 2025-01-16 14:10 I'm trying to send eMail via code using TIdSMTP but I'm having problems encoding Greek. I have the code       IdMessage1.Clear;                     IdMessage1.CharSet := 'UTF-8';                     with IdMessage1.Recipients.Add do begin                             Address := eMail.text; // a TEdit component                             Name    := eMail.text;                         end;                     IdMessage1.From.Name    := 'Ελληνικό κείμενο'; // doesn't transfer Greek           IdMessage1.From.Address := 'noreply@server.gr';                     IdMessage1.MsgId        := IdMessage1.From.Address := 'κείμενο στα Ελληνικά';                     IdMessage1.Subject      := 'Ελληνικό κείμενο eMail';                     IdMessage1.Body.add(UTF8Encode('Ελληνικά : '+aStringValue); // only this Line shows Greek chars                     IdMessage1.Body.add('');                     IdMessage1.Body.add(UTF8Encode('άλλο κείμενο στα Ελληνικά')); // this Line shows strange chars                     IdMessage1.CharSet := 'utf-8';                     IdMessage1.ContentTransferEncoding := 'base64';    TRY       Connect();       Send(IdMessage1);    FINALLY       disconnect();    END; The message is sent but there are strange characters in place of Greek. If I write the three add commands as one ie. IdMessage1.Body.Add(UTF8Encode('Ελληνικά: ' + aStringValue                     +#13#13'άλλο κείμενο στα Ελληνικά')); then they all appear normally in Greek. If I use the function EncodeString(const AText, ACharSet: string): string;        var          Encoder: TIdEncoderMIME;        begin          Encoder := TIdEncoderMIME.Create(nil);          try            Result := Format('=?%s?B?%s?=', [ACharSet, Encoder.EncodeString(AText, IndyTextEncoding_UTF8)]);          finally            Encoder.Free;          end;        end; and send the message with IdMessage1.From.Name := EncodeString('Ελληνικό κείμενο', 'UTF-8'); then the message displays Greek in the "From" field. But no matter what I do I can't get it to work with the "subject" field. ChatGPT gave me the above solutions but it failed for the "subject" field. Has anyone encountered these problems and found solutions? ---------------------------------------------------------------------- DragoRosso · 2025-01-16 17:36 I think (related to old RFC5322, RFC5321 and RFC822) that the address the of e-mail SHOULD be in ASCII SET (numbers, letters and some other chars). I remember something about a RFC proposal to expand to UTF-8, but I think that it's still not approved. So, if you use utf-8 chars is highly possible that your e-mail is rejected. ---------------------------------------------------------------------- TRon · 2025-01-16 18:01 https://en.wikipedia.org/wiki/International_email ---------------------------------------------------------------------- DragoRosso · 2025-01-16 19:11 Quote from: TRon on January 16, 2025, 07:01:01 pmhttps://en.wikipedia.org/wiki/International_email They (new RFC) are still in proposal state ... or I'm wrong ? ---------------------------------------------------------------------- Remy Lebeau · 2025-01-17 08:30 In order to use non-ASCII characters in the header of the email, you need to use the TIdMessage.OnInitializeISO event, eg: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMyForm.IdMessage1InitializeISO(  var VHeaderEncoding: Char; var VCharSet: string);begin  VHeaderEncoding := 'B';  VCharSet := 'utf-8';end;