How Send Email (Gmail, Hotmail, Yahoo) lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Ericktux · 2016-05-30 14:25 hello my friends, as I send an email from my app. ---------------------------------------------------------------------- eric · 2016-05-30 17:33 I'm not sure if that's a question, but if it is, then xmailer-master is an easy solution: https://github.com/silvioprog/xmailer ---------------------------------------------------------------------- Ericktux · 2016-05-30 17:38 Hi eric, thank for you answer, effectively is a question ---------------------------------------------------------------------- Ericktux · 2016-05-31 14:00 Hi, I was testing the example (xmailer) but not happen nothing, this is mi code: 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 TForm1.Button3Click(Sender: TObject);var  Mail: TSendMail;begintry  try    // Mail    Mail := TSendMail.Create;    Mail.Sender := 'ericktux ';    Mail.Receivers.Add('client_01@hotmail.com');    Mail.Subject := 'hello';    Mail.Message.Add('how are you');    // SMTP    Mail.Smtp.UserName := 'ericktux@hotmail.com';    Mail.Smtp.Password := 'mypasswords';    Mail.Smtp.Host := 'smtp.live.com';    Mail.Smtp.Port := '25';    Mail.Smtp.SSL := True;    Mail.Smtp.TLS := True;    Mail.Send;  except    on E:Exception do    ShowMessage('error');  end;  finally    Mail.Free;  end;end; any help ---------------------------------------------------------------------- rvk · 2016-05-31 14:18 Post 25? Did you try port 587? And did you put the OpenSSL-library in your .exe directory? (You'll need the 64bit versions if you have Lazarus 64bit and the 32bit for Lazarus 32 bit) If you don;t have these in your exe-directory your program will fail silently. If you don't have those you can look here: https://indy.fulgan.com/SSL/ ---------------------------------------------------------------------- Ericktux · 2016-05-31 14:39 Thank you rvk, i put 587, but i get the same error message  Adjunt the image of my files. ---------------------------------------------------------------------- rvk · 2016-05-31 14:42 Quote from: Ericktux on May 31, 2016, 04:39:15 pmAdjunt the image of my files. Ok, you have the OpenSSL-dlls in your exe directory. But are you sure they are the correct version/bitness? If you have Lazarus 1.6 on Windows 64bit you probably have 64bit version of Lazarus. In which case you would also need the 64bit version of the OpenSSL-dlls. ---------------------------------------------------------------------- rvk · 2016-05-31 14:51 Quote from: Ericktux on May 31, 2016, 04:39:15 pmThank you rvk, i put 587, but i get the same error message  O, and you still didn't mention which error. ---------------------------------------------------------------------- rvk · 2016-05-31 14:55 I think I found it. You need to add this: 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 Mail.Smtp.Port := '587'; // <-- use this portMail.Smtp.FullSSL := false;Then it worked for me with smtp.live.com ---------------------------------------------------------------------- Ericktux · 2016-05-31 15:47 Thank You friend rvk, now works  the steps that I followed: (sorry i using google traslate) I'm using: * Win10x64 * Lazarus 1.6 32bits 1. i downloaded "xmailer-master.zip" from: https://github.com/silvioprog/xmailer 2. I installed "xmailerpkg.lpk" 3. i copied dll (libeay32.dll and ssleay32.dll) from "xmailer- master\3rdparty\openssl\win32" (o https://indy.fulgan.com/SSL/) to the directory of my project. 3. In lazarus Proyect -> Inspector of Project -> Add -> new requirement -> name of package, and choose Xmailerpkg. 4. In Edit Source code, i put: 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 unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, XMailer; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  Mail: TSendMail;beginMail := TSendMail.Create;try    // Mail    Mail.Sender := 'ericktux ';    Mail.Receivers.Add('client_01@hotmail.com');    Mail.Subject := 'Hello';    Mail.Message.Add('How are you');    mail.Attachments.Add('C:\saludos.log');  // for send files, optional  // SMTP    Mail.Smtp.UserName := 'ericktux@hotmail.com';    Mail.Smtp.Password := 'mypassword';    Mail.Smtp.Host := 'smtp.live.com';    Mail.Smtp.Port := '587';    //Mail.Smtp.SSL := True;    mail.Smtp.FullSSL:=false;  // thanks rvk    Mail.Smtp.TLS := True;    Mail.Send;    ShowMessage('SUCCESS :) ');  {except    on E:Exception do   end;}  finally    Mail.Free;  end;end;end. Works for Hotmail, Gmail and Yahoo ---------------------------------------------------------------------- luk2009 · 2018-05-31 03:07 https://github.com/silvioprog/xmailer this link not working. anybody have a copy? ---------------------------------------------------------------------- marcov · 2018-05-31 07:27 This seems to be a clone: https://github.com/MFernstrom/xmailer ---------------------------------------------------------------------- tudi_x · 2018-05-31 07:34 Also: https://github.com/TARAPascal/xmailer ---------------------------------------------------------------------- af0815 · 2018-05-31 08:52 I think its now a plugin in Brook-framework and moved to a new location (and alive) https://github.com/silvioprog/brookframework/tree/master/plugins/xmail er ---------------------------------------------------------------------- wp · 2018-05-31 08:56 XMailer is also available directly within Lazarus via OnlinePackageManager. ---------------------------------------------------------------------- luk2009 · 2018-05-31 12:22 Thanks for your answers ---------------------------------------------------------------------- cgd · 2019-08-04 17:36 Thank you so much for this topic... I was several days trying to understand why my old routines to send emails stopped working since some months... the SSL and TLS properties need to be defined nowadays to work with many email providers. I use Lazarus 1.6, FreePascal 3.0.0 My email example program is working now in Windows10, 32b. But I also have to compile it in Ubuntu 32bits and Raspbian Stretch for Raspberry ARM... (I didn't do that yet) Questions: do I have to provide dlls for OpenSSL with my Raspberry application? In affirmative case, which ones? (I see librarys por Windows and Linux, could I use the Linux ones for Raspbian?) Thank you very much !! ---------------------------------------------------------------------- toby · 2019-08-04 21:15 cgd xmailer uses the synapse libraries so you must have them installed on your windows box - you can use the same files on your linux boxes they will be bel recompiled for linux when you compile your xmailler program the synapse files will also work on the rpi you probably already have the linux openssl files on your linux boxes - if not they are very easy to install ---------------------------------------------------------------------- cgd · 2019-11-07 20:24 xmailer is working great for me in win xp 32bits, win 10 64 bits, and raspbian stretch (raspberry pi3B+)!! I still did not tested in ubuntu 32 and 64 bits... Question: Has anyone used xmail to send an email with a html body? Could share a simple example of how to? Thank you very much! ---------------------------------------------------------------------- cgd · 2019-11-07 21:06 I got it... it's simple: function MailSimple(.....) Var     Mail : TSendMail; begin     ...     ...       Mail.ContentType := ctTextPlain ;    //for plain text    //or       Mail.ContentType := ctTextHTML ;   //for html text    ... end; ---------------------------------------------------------------------- Ericktux · 2024-10-20 04:03 Currently today 10/19/2024 I can no longer send emails  , I attach the error images that appear, if someone manages to use it or solve it please can you help me here ---------------------------------------------------------------------- Thaddy · 2024-10-20 05:45 Version of your crypto lib(s) are too old, so the authentication fails. Your are probably using a crypto lib version (any, e.g. openssl) that does not support tls 1.3, although 1.2 might still work. This is an ever recurring problem and I have posted this or similar answers in their hundreds. See wikipedia: https://en.wikipedia.org/wiki/Version_history_for_TLS/SSL_support_in_w eb_browsers and https://developer.mozilla.org/en-US/docs/Glossary/TLS For good measure, this goes for ALL browsers, not just Firefox. https://support.mozilla.org/en-US/kb/secure-connection-failed-firefox- did-not-connect ---------------------------------------------------------------------- paweld · 2024-10-20 07:01 In general, it is Google that has blocked the ability to send emails when authenticating with a login and password. You must use OAuth or set up an additional password for the app: https://support.google.com/a/answer/9003945 ---------------------------------------------------------------------- silvercoder70 · 2024-10-20 09:19 Think that hotmail (office etc.) also require OAuth2 today as well. ---------------------------------------------------------------------- Ericktux · 2026-01-08 00:35 Hello friends, happy new year! I have a question: has anyone been able to find a way to send emails these days? ---------------------------------------------------------------------- Ericktux · 2026-01-08 02:11 Hi friends, today, January 7, 2026, I managed to send emails very easily  . Here's how: 1. First, create an "app password" from your Google account. Here's the direct link: https://myaccount.google.com/apppasswords 2. Give it any name, and your "app password" will be generated. 3. Now, just enter it instead of your current password. See the example: 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 program demo; {$mode objfpc}{$H+} uses  XMailer, SysUtils; var  Mail: TSendMail;begin  Mail := TSendMail.Create;  try    Mail.Sender := 'Erick ';    Mail.Receivers.Add('micliente@gmail.com');     Mail.Subject := 'Prueba de envío';    Mail.Message.Add('Este correo fue enviado correctamente.');     Mail.Smtp.UserName := 'erick1@gmail.com';    Mail.Smtp.Password := 'HERE_YOUR_APP_PASSWORD';    Mail.Smtp.Host := 'smtp.gmail.com';    Mail.Smtp.Port := '587';    Mail.Smtp.SSL := False;    Mail.Smtp.TLS := True;     Mail.Send;    WriteLn('E-mail sent successfully!');  except    on E: Exception do      WriteLn('Error: ', E.Message);  end;   Mail.Free;end. This might be helpful: 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 //TLS – puerto 587Mail.Smtp.UserName := 'erick1@gmail.com';Mail.Smtp.Password := 'HERE_YOUR_APP_PASSWORD';Mail.Smtp.Host := 'smtp.gmail.com';Mail.Smtp.Port := '587';Mail.Smtp.SSL := False;Mail.Smtp.TLS := True; // SSL – puerto 465Mail.Smtp.UserName := 'erick1@gmail.com';Mail.Smtp.Password := 'HERE_YOUR_APP_PASSWORD';Mail.Smtp.Host := 'smtp.gmail.com';Mail.Smtp.Port := '465';Mail.Smtp.SSL := True;Mail.Smtp.TLS := False; ✔ What it CAN do: Send emails via SMTP Receive via IMAP (if used) Works 24/7 Doesn't ask for confirmations or pop-ups Even though the password works perfectly, Gmail does limit sending: ~500 emails/day (personal accounts) ~2000 emails/day (Google Workspace) Limit per minute (anti-spam) Repetitive content → suspicious PD: I downloaded the DLL files from here (libeay32.dll and ssleay32.dll of 32bits) https://indy.fulgan.com/SSL/ espero les pueda ayudar mi aporte, saludos amigos ---------------------------------------------------------------------- delphius · 2026-01-08 12:02 Quote from: Ericktux on January 08, 2026, 01:35:42 amHello friends, happy new year! I have a question: has anyone been able to find a way to send emails these days? This is all good, with the help of XMailer and OpenSSL. Try it without them)