LNET sendmail UTF8 lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- vexal · 2011-09-12 13:38 Hi, When i am sending mail with accent (i'm french) with the sendmail method of lsmtp, i am receiving mail in wrong encoding. For example, if i send QuoteTest éaà@rzùkt&gùlv* i will receive QuoteTest éaà @rzùkt&gùlv*. I am under CentOs 6 Linux with Lazarus 0.9.30 and lnet 0.6.5 What did i need to do ? ---------------------------------------------------------------------- felipemdc · 2011-09-12 13:58 What about some sample code? ---------------------------------------------------------------------- vexal · 2011-09-12 14:19 Of course : Code: [Select]SMTPClient.SendMail('test1@example.com', 'test2@example.com', 'test', 'Test éaà@rzùkt&gùlv*'); ---------------------------------------------------------------------- Arbee · 2011-09-12 14:19 The second piece of text I recognize as UTF-8 characters, displayed as if it is ASCII text, in which case you see the separate characters (bytes) which make up each UTF-8 character.  For instance the é character occupies two bytes when viewed separately as ASCII come out as é. So it looks like your email is sent as UTF8 alright. ---------------------------------------------------------------------- vexal · 2011-09-12 14:24 I just test this under windows and i have no problem. Even if i try Code: [Select]SMTPClient.SendMail('test1@example.com', 'test2@example.com', 'test', Utf8ToAnsi('Test éaà@rzùkt&gùlv*')); i have a problem under linux. ---------------------------------------------------------------------- Arbee · 2011-09-12 14:29 utf8toSys does not work either? ---------------------------------------------------------------------- vexal · 2011-09-12 14:33 nope, the same ---------------------------------------------------------------------- Arbee · 2011-09-12 14:58 By the way ... what are you receiving the email with?   Is that a separate application and is that Unicode enabled? (I'm not a Linux expert as you may gather) ---------------------------------------------------------------------- vexal · 2011-09-12 15:02 I am receiving email in Thunderbird under windows. It can display correctly utf8 messages, usually. I tried with a webmail under linux but the same than in thunderbird : UT8 is not decoded. ---------------------------------------------------------------------- Arbee · 2011-09-12 15:26 OK, you can't set the browser to show UTF8?  If not, I guess it all boils down to not sending the email as UTF8, if I understand you correctly.  If UTF8ToAnsi nor UTF8ToSys works, then I'm afraid I must hand this over to a Linux FPC-er. ---------------------------------------------------------------------- vexal · 2011-09-12 15:29 Quote from: Arbee on September 12, 2011, 05:26:15 pmI guess it all boils down to not sending the email as UTF8 I am afraid you are rigth. Thank you anyway ! ---------------------------------------------------------------------- Almindor · 2011-09-13 16:04 You need to ensure that the receiving application expects UTF-8. SMTP doesn't handle encoding itself, it just sends what's fed to it. But you should use mimetypes to specify that your e-mail is UTF-8. I'm a bit short on time atm. to look it up but it's all about the mimetype header in the mail body. ---------------------------------------------------------------------- vexal · 2011-09-13 16:37 Ok, Thank you !  I will look at this tomorow ---------------------------------------------------------------------- vexal · 2011-09-14 09:45 Hi, you were rigth ! I modified line 772 in lsmtp like this and it works : Code: [Select]Data('Content-type: text/plain; charset=UTF-8' + CRLF + 'From: ' + From + CRLF + 'Subject: ' + Subject + CRLF + 'To: ' + FSL.CommaText + CRLF + CRLF + Msg); But this is not very clean. i prefer to not modify the library. Do you know how i can add the header without modifying the lib ?