Email with synapse lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- ginoo · 2025-10-28 17:30 What's the correct way to send an email with plain text, HTML text, and attachments? Thanks. ---------------------------------------------------------------------- paweld · 2025-10-29 04:37 The easiest way is to use the XMailer component: https://github.com/MFernstrom/xmailer/tree/master - is also available in OPM. Here is an example of sending an HTML message with alternative text using synapse: https://forum.lazarus.freepascal.org/index.php/topic,46 266.msg377801.html#msg377801 ---------------------------------------------------------------------- Thaddy · 2025-10-29 05:41 @Paweld Yes, but note that the third-party openssl is out-dated. You need to download new binaries for Openssl. The versions in the repository are over 8 years old and won't work with modern email servers. (Modern protocols not supported and legacy protocols removed) ---------------------------------------------------------------------- ginoo · 2025-10-29 05:51 Quote from: paweld on October 29, 2025, 05:37:00 amThe easiest way is to use the XMailer component: https://github.com/MFernstrom/xmailer/tree/master - is also available in OPM. Here is an example of sending an HTML message with alternative text using synapse: https://forum.lazarus.freepascal.org/index.php/topic,46 266.msg377801.html#msg377801 Thanks paweld for your reply. I've already seen your example, the problem is that the attachments are missing. I did it by putting a multipart/mixed as the root, but it seems very cumbersome, and I don't think it's the right solution. That's why I'm wondering if anyone has a better solution. ---------------------------------------------------------------------- paweld · 2025-10-29 07:21 @Thaddy: My post is from 5 years ago, when it worked fine with OpenSSL 1.0.2. Currently, just add “3” to the unit names and it will work fine with OpenSSL 3.x. @ginoo: The attachment contains a sample project that allows you to send HTML messages, alternative text and attachments. All you need to do is compile and copy the OpenSSL 3.x libraries (libssl-3.dll and libcrypto-3.dll for 32-bit or libssl-3-x64.dll and libcrypto-3-x64.dll for 64-bit) to the program directory. ---------------------------------------------------------------------- ginoo · 2025-10-30 05:45 @Thaddy: Thanks for your note. @paweld: Out of curiosity, could you tell me what package lpdinternet is? Thanks ---------------------------------------------------------------------- paweld · 2025-10-30 06:30 Sorry, this is my package that groups the packages I use. Remove it from the requirements and add “laz_synapse" - see attachment ---------------------------------------------------------------------- ginoo · 2025-10-30 08:42 Dear paweid, I understood it was laz_synapse, but I think there was something interesting inside lpdinternet. Thanks anyway. ---------------------------------------------------------------------- paweld · 2025-10-30 09:23 Hi, Most of it is my overlay for Synapse, e.g., https://github.com/paweld/especies/blob/master/shared/LPDNetU.pas is part of this package. There is also a class for simplified email sending. But I also have some things related to paid components there, which is why I can't share it as it is at the moment. When I have some free time, I'll try to separate the email sending and share it. ---------------------------------------------------------------------- ginoo · 2025-10-30 15:59 You know, there are some messages with the same text that, if I send them from Synapse, go to spam, but if I send them from Thunderbird, it goes as not spam. This is starting to get interesting. ---------------------------------------------------------------------- rvk · 2025-10-30 17:03 Quote from: ginoo on October 30, 2025, 04:59:44 pmYou know, there are some messages with the same text that, if I send them from Synapse, go to spam, but if I send them from Thunderbird, it goes as not spam. This is starting to get interesting. You can save a message from your Sent messages in Thunderbird to a EML file. Then you can investigate what Thunderbird is sending as headers. For example, if you omit a Date, From or Mime-Version header, this could be counted towards the spam-count. Also malformed messages, where Mime-parts are not connected correctly, will often be counted as spam. ---------------------------------------------------------------------- ginoo · 2025-10-30 17:31 Sorry, I didn't explain myself well. I'm testing from my mail server with dmarc, dkim, and spf. It works on almost all providers like Gmail, Outlook, and others. Libero.it, however, accepts almost all of them. However, this is a problem for individual providers, and it would be interesting to understand these headers. X-OX-Status: Spam X-Brightmail: 1.00 X-CNFS-Analysis: v=2.4 cv=ZdYdNtVA c=1 sm=1 tr=0 ts=69039348 cx=a_exe:a_idp_f p=QhnmdGnfZl10ibMM-eB4:22 a=vrHvosX20Yrq0acvc5QOjQ==:117 a=vrHvosX20Yrq0acvc5QOjQ==:17 a=HpEJnUlJZJkA:10 a=MKtGQD3n3ToA:10 a=x6icFKpwvdMA:10 a=lf-3UfneMEIA:10 a=Vb95fvYOAAAA:8 a=5zAI1xus6w9RZBkyUOcA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=LtFBKr6MBRdo3qlOK5sA:9 a=pdAKAx2EbHsGrF4G:21 a=_W_S_7VecoQA:10 a=-FEs8UIgK8oA:10 a=m7Hb_mE0HxHCsgcvcTXk:22 a=glO-dtapxrrFZ_xorp8i:22 a=NWVoK91CQySWRX1oVYDe:22 a=eeDtFMHqlkPJeBvn9BwJ:22 a=_u5OvhVQolUJ3TCjunbR:22 a=WG9Y6cERWHvKDdiOagKf:22 a=poXaRoVlC6wW9_mwW8W4:22 a=LCPei-_akW1o0B1TN7Yk:22 a=rpXtYnK6aTl2ddkKRDiu:22 a=p-dnK0njbqwfn1k4-x12:22 a=w6lp42yqJsgZLFNJYmHW:22 ---------------------------------------------------------------------- rvk · 2025-10-30 17:41 Quote from: ginoo on October 30, 2025, 06:31:36 pmSorry, I didn't explain myself well. I'm testing from my mail server with dmarc, dkim, and spf. It works on almost all providers like Gmail, Outlook, and others. Libero.it, however, accepts almost all of them. However, this is a problem for individual providers, and it would be interesting to understand these headers. Those spam headers don't really show why it is seen as spam. Can you provide the complete headers and body that are send? Especially the resulting body could be malformed (the html parts). Or you didn't include From or Date in the headers. Etc. ---------------------------------------------------------------------- ginoo · 2025-10-30 18:31 Quote from: rvk on October 30, 2025, 06:41:31 pmQuote from: ginoo on October 30, 2025, 06:31:36 pmSorry, I didn't explain myself well. I'm testing from my mail server with dmarc, dkim, and spf. It works on almost all providers like Gmail, Outlook, and others. Libero.it, however, accepts almost all of them. However, this is a problem for individual providers, and it would be interesting to understand these headers. Those spam headers don't really show why it is seen as spam. Can you provide the complete headers and body that are send? Especially the resulting body could be malformed (the html parts). Or you didn't include From or Date in the headers. Etc. I deleted the domain name to avoid spam X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-Path: Delivered-To: x@inwind.it Received: from dcd-09.iol.local ([10.103.10.25])    by dcbackend-45.iol.local with LMTP    id gCyVOxE/A2llTAAAw+SqjQ    (envelope-from )    for ; Thu, 30 Oct 2025 11:33:54 +0100 Received: from dcp-17.iol.local ([10.103.10.25])    by dcd-09.iol.local with LMTP    id iGGFOxE/A2lVKQAAsAR62Q    (envelope-from )    for ; Thu, 30 Oct 2025 11:33:53 +0100 Received: from libero.it ([10.103.10.25])    by dcp-17.iol.local with LMTP    id uFveOhE/A2kX/AAAXmhDwA    (envelope-from )    for ; Thu, 30 Oct 2025 11:33:53 +0100 Received: from srv.x.cloud ([xx.xx.240.236])    by smtp-25.iol.local with ESMTPS    id EPybvDhKFBY4tEPybv1ey7; Thu, 30 Oct 2025 11:33:53 +0100 X-IOL-DMARC: pass con il dominio .cloud X-IOL-DKIM: pass con il dominio d=.cloud X-IOL-SPF: pass con l'IP xx.xx.240.236;x.cloud X-IOL-SEC: _SPFOK_DKIMOK_DMARCOK x-libjamoibt: 2601 Received-SPF: pass X-OX-Status: Spam X-Brightmail: 1.00 X-CNFS-Analysis: v=2.4 cv=ZdYdNtVA c=1 sm=1 tr=0 ts=69033f11 cx=a_exe:a_idp_f  p=QhnmdGnfZl10ibMM-eB4:22 a=vrHvosX20Yrq0acvc5QOjQ==:117  a=vrHvosX20Yrq0acvc5QOjQ==:17 a=HpEJnUlJZJkA:10 a=MKtGQD3n3ToA:10  a=x6icFKpwvdMA:10 a=lf-3UfneMEIA:10 a=Vb95fvYOAAAA:8 a=rDh0EN0UpqhW1PnOuxUA:9  a=1mYn72MaRZ_Nbv-_:21 a=_W_S_7VecoQA:10 a=QEXdDO2ut3YA:10 a=-FEs8UIgK8oA:10  a=6EhliRRyB9OGutLsT18A:9 a=3ZKOabzyN94A:10 a=m7Hb_mE0HxHCsgcvcTXk:22  a=glO-dtapxrrFZ_xorp8i:22 a=NWVoK91CQySWRX1oVYDe:22 a=_u5OvhVQolUJ3TCjunbR:22  a=WG9Y6cERWHvKDdiOagKf:22 a=rpXtYnK6aTl2ddkKRDiu:22 a=eeDtFMHqlkPJeBvn9BwJ:22  a=poXaRoVlC6wW9_mwW8W4:22 a=LCPei-_akW1o0B1TN7Yk:22 a=p-dnK0njbqwfn1k4-x12:22  a=w6lp42yqJsgZLFNJYmHW:22 Authentication-Results: smtp-25.iol.local;    dkim=pass header.d=x.cloud header.b=y4aEeTQZ;    bimi=skipped header.d=x.cloud header.selector=default  policy.authority=none Message-ID: <1d1edd1bbed573dc0a6b65288ac50c77@smtp-25.iol.local> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=x.cloud;    s=mail; t=1761820433;    bh=AF3CGkhnVwxqj9f9drLNP07Ld6Nvc4E7MeohQE4760M=;    h=From:To:Subject:Date:From;    b=y4aEeTQZetREDfTsH0MIzqqkzQPFhhJpn5UT5I4O9PucQBJyPVxvsIboQ0dELt7Be     u6IA6po5waWG9PqTcu1u8QTWFP4A9dE2TrvzqKHcvtAHma/WYK0PhWcC8m75k8nOVC     yR5otBQ8lUNWxBAl3PCli4xAU6zrJuyK/IrSVNNIqMTwztx6VKnCjA3Jwdyh3Y3IQb     9qKHfpU23CgH7GVFBWI+u4caexwa82hkNMK/fbwoQTQaOm+icxt52Dj5GQribgcQJX     AepALlU80iliEHsAMzVwaAc9bVp049Rz7uMlP2ggFXvkt28OwhWBHFojP9fMbXZ/DM     IClwzOFijWkrA== Received: from gabriele-P5K (mobiledyn-62-240-135-50.mrsn.it [62.240.135.50])    by srv.x.cloud (Postfix) with ESMTPSA id 09A4B1C0343    for ; Thu, 30 Oct 2025 11:33:52 +0100 (CET) From: "ASD TEST" To: x@inwind.it Subject: Invio credenziali per primo accesso area riservata. Date: Thu, 30 Oct 2025 11:33:52 +0100 MIME-Version: 1.0 (produced by Synapse) X-mailer: Synapse - Pascal TCP/IP library by Lukas Gebauer Content-type: Multipart/related;  boundary="027B4202_2372C4D4_Synapse_boundary" Content-Description: Multipart message X-CMAE-Envelope: MS4xfEN9KYLj6HbOwgjJYRNN/5EI+/NkHgzRfa8A1f1GD1ItTWTEk /Ah+wPnMKWfVSUPhBAhqLH0CTwgEmBs9CKAmpbxz1pAU6aRnIzT7+zXSFkvJrWjg49T  KQfq9ZCsX0x1GcaBLemrV885C9Juw1LYl3afhBXzacxabEgMBFMnCOzafBhq1YKEweBPe Uwx8b9o9J75KG2udtUqvTS16JokmZc= --027B4202_2372C4D4_Synapse_boundary Content-type: text/html; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable Content-Disposition: inline Content-Description: HTML text Buongiorno,
Vi inviamo le credenziali per il=  primo accesso all=E2=80=99area riservata per utente test=  che sono:

Mail : x@inwind.it
Password :=  n8.k71zGto

Url di accesso : https://gabry.x.cloud
Da qui potrete vedere le quote, le scadenze, stampare ricevute,=  effettuare pagamenti.
Vi ricordiamo che al primo accesso, Vi verr=C3= =A0 chiesto di modificare la password.
Contattateci per qualsiasi=  chiarimento.

Cordiali saluti.
ASD TEST
VIA TEST
C.F.=  TEST


n.b.: attivare i popup per=  utilizzare tutte le funzionalit=C3=A0 del sito.


--027B4202_2372C4D4_Synapse_boundary Content-type: Multipart/alternative;  boundary="027B4204_2372C4D4_Synapse_boundary" Content-Description: Multipart message --027B4204_2372C4D4_Synapse_boundary Content-type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Description: Message text Buongiorno, Vi inviamo le credenziali per il primo accesso all’area riservata per utente test che sono: Mail : x@inwind.it Password : n8.k71zGto Url di accesso :  _https://gabry.x.cloud_ Da qui potrete vedere le quote, le scadenze, stampare ricevute, effettuare pagamenti. Vi ricordiamo che al primo accesso, Vi verrà chiesto di modificare la password. Contattateci per qualsiasi chiarimento. Cordiali saluti. ASD TEST VIA TEST C.F. TEST n.b.: attivare i popup per utilizzare tutte le funzionalità del sito. --027B4204_2372C4D4_Synapse_boundary-- --027B4202_2372C4D4_Synapse_boundary-- ---------------------------------------------------------------------- rvk · 2025-10-30 18:45 You have a link in the html and text part. Did you also try it without that link? Then you have a multipart boundary with just one part inside it. Twice. That's what I meant with malformed parts and boundaries. I also thought everything should be in a boundary over all. Also... The text part should be related or alternative to html. That's also not the case here The way you structure the boundary and parts is important. https://glockapps.com/blog/parts-of-email-how-to-structure-your- message/ https://docs.mspintegrations.com/documentation/troubleshooting/email- structures/understanding-multipart-emails (And if you are including inline images and attachments this all becomes exponentially more complex.) That in combination with the spaminess factor of the content could well be the reason for marking it as spam. ---------------------------------------------------------------------- ginoo · 2025-10-30 18:54 Quote from: ezlage on October 30, 2025, 07:38:06 pmSubmitting the headers you provided to that analysis tool, we have information that SPF and DKIM failed, and that DMARC is missing. And the x.cloud domain isn't even registered, so it couldn't possibly have SPF, DKIM, and DMARC configured. Setting up these things in an internal DNS zone isn't enough, unless the destination email service is also internal. As a rule, you need to configure it in an external DNS zone, which requires having the domain registered. I wrote it above, I changed the domain to avoid spam, if you look at the headers you will see that everything is ok. ---------------------------------------------------------------------- ginoo · 2025-10-30 18:56 Anyway, thanks to both of you. I'll try tomorrow. ---------------------------------------------------------------------- rvk · 2025-10-30 19:15 Seeing the number of a-records in the X-CNFS-Analysis header (which would mean multiple rules are hit) I guess it has more to do with content. BTW. You can also send the mail to some spam tester to see what it makes of it. For example https://www.mail-tester.com/ and https://unspam.email/ and https://www.mailgenius.com/ and https://www.experte.com/spam-checker and https://mailchecker.net/ and many many more ---------------------------------------------------------------------- rvk · 2025-10-31 08:15 Quote from: ginoo on October 31, 2025, 07:40:41 amhttps://www.mail- tester.com/  gives me 10/10 Then it must be content related (as I said earlier, seeing those X-CNFS-Analysis a records). For example spamassassin has lots of rules for content. If you have white text on white background. If you have double spaces. And thousands of other things. The only one who can diagnose those headers is Cloudmark (I think the mail goes through Cloudmark Authority). I haven't seen anyone else decrypting those headers. (someone asked here: https://github.com/mgeeky/decode-spam- headers/issues/5)