How Send Email (Gmail, Hotmail, Yahoo) lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Bandy · 2022-03-15 17:21 Hello, I want to send email from Yahoo to Gmail and I receive error message from attachment picture. How can be FIXED? This is my 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 unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,  RTTICtrls, XMailer, DateUtils, WinInet; type   { TForm1 }   TForm1 = class(TForm)    Button4: TButton;    procedure Button4Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure SendMail(nume, mesaj:string);var    Mail: TSendMail;begin  Mail := TSendMail.Create;  try      // Mail      Mail.Sender := 'bandy@yahoo.com';      Mail.Receivers.Add('bandy@gmail.com');      Mail.Subject := 'Notify';      Mail.Message.Add(mesaj);      //Mail.Attachments.Add('C:\No File.txt');  // to send files, optional      // SMTP      Mail.Smtp.UserName := 'bandy@yahoo.com';      Mail.Smtp.Password := 'password';      Mail.Smtp.Host := 'smtp.mail.yahoo.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; procedure TForm1.Button4Click(Sender: TObject);begin  SendMail('','test');end; end. [Edited to add code tags - PLEASE read How to use the Forum.] ---------------------------------------------------------------------- rvk · 2022-03-15 18:04 Quote from: Bandy on March 15, 2022, 06:21:30 pmI want to send email from Yahoo to Gmail and I receive error message from attachment picture. How can be FIXED? What version of openssl are you using? Try one of the later versions. ---------------------------------------------------------------------- Bandy · 2022-03-15 18:09 How can I find version of openssl? ---------------------------------------------------------------------- rvk · 2022-03-15 18:18 You didn't put any openssl dll besides your exe program? In that case your system might not even have an openssl installed which would also result in that error. What OS and what bitness of FPC are you using? 32 bit or 64 bit? Download the correct openssl for bitness here https://indy.fulgan.com/SSL/ And put those dll besides you .exe and try again. (For example openssl-1.0.2u-x64_86-win64.zip for FPC 64 bit) ---------------------------------------------------------------------- Bandy · 2022-03-15 18:23 Windows 10 64bit and Lazarus 2.2.0 ---------------------------------------------------------------------- rvk · 2022-03-15 18:30 Quote from: Bandy on March 15, 2022, 07:23:02 pmWindows 10 64bit and Lazarus 2.2.0 Then unzip the openssl-1.0.2u-x64_86-win64.zip from earlier link to your exe directory. (If Lazarus itself is 64 bit too) ---------------------------------------------------------------------- Bandy · 2022-03-15 18:35 I done what you told me and still the same error. ---------------------------------------------------------------------- Bandy · 2022-03-15 18:37 I have Lazarus 2.2.0 for 64bit. ---------------------------------------------------------------------- rvk · 2022-03-15 18:40 Quote from: Bandy on March 15, 2022, 07:37:46 pmI have Lazarus 2.2.0 for 64bit. Then you should keep those dll files in the exe directory. They are needed (and depending on the system version isn't always best). Not sure why you still get the error then. ---------------------------------------------------------------------- Bandy · 2022-03-16 12:48 Please HELP ME! I want to send email from Yahoo to Gmail and I receive error message from attachment picture. How can be FIXED? My code is above. ---------------------------------------------------------------------- Remy Lebeau · 2022-03-16 16:38 The error message has nothing to do with OpenSSL itself, so you need to stop focusing on that.  The error is coming from a failed SMTP MAIL FROM command, long after an SSL/TLS session has been negotiated, and the Yahoo account has been logged in to.  Though, I do find it interesting that the 2nd line of the exception's Message (which is supposed to contain the actual SMTP error message from the server) is basically nonsense, it doesn't look like a valid SMTP error.  Which could indicate a corrupted SMTP communication. Something else I notice - in the source code of xmailer's TSendMail.Send() method, when it calls Synapse's TSmtpSend.MailFrom() method, it is setting the Size parameter to an incorrect value.  It is setting the parameter to the character length of the Sender's email address, but it should be setting the parameter to the byte size of the email message instead.  So, that could potentially be causing Yahoo to reject the command. ---------------------------------------------------------------------- rvk · 2022-03-18 20:25 Quote from: Bandy on March 18, 2022, 09:15:58 pmI want to send email from Yahoo to Gmail and I receive error in attachment. How can be fixed? Please don't delete my post. Remy already answered you? Fix the xmailer code yourself to see if he is right (i.e. changing the size parameter in that line) or don't use xmailer. [Edited to make sense after two identical topics merged. OP has been banned in the meantime (not by me).] ---------------------------------------------------------------------- Bandy · 2022-03-18 20:47 And what should I use instead of xmailer, please? ---------------------------------------------------------------------- rvk · 2022-03-18 21:04 Quote from: Bandy on March 18, 2022, 09:47:19 pmAnd what should I use instead of xmailer, please? You could use Synapse directly. Xmailer is just a wrapper around that. There are plenty of examples here on the forum. (Search for part of the code like FullSSL and you'll find them) For example https://forum.lazarus.freepascal.org/index.php/topic,54733 .msg406913.html#msg406913 Otherwise you can fix xmailer.pas at around line 522 FSmtp.MailFrom(VSenderAddr, Length(VSenderAddr)) The length should be of your data (not sure at this moment what exactly). You could also try setting it to 0 (I thought that size was ommited in that case).