[Lazarus] Sending e-mail from within Lazarus

Denis Kozlov dezlov at gmail.com
Thu May 10 18:15:35 CEST 2018


Try the latest trunk version of Synapse code:
http://sourceforge.net/p/synalist/code/HEAD/tree/trunk/

You'll also need OpenSSL binaries:
https://wiki.openssl.org/index.php/Binaries

Here is a snippet of a working connection routine, although tested in 
Delphi only:

================================================

uses
   // "ssl_openssl" unit is required to use SSL / TLS
   mimemess, mimepart, synachar, ssl_openssl;

type
   TMailerSecurity = (
     msNONE,
     msSTARTTLS,
     msSSLTLS
   );

procedure TMailer.Connect(const AHost: String; APort: Integer;
   ASecurity: TMailerSecurity; AAuthenticate: Boolean;
   const AUsername, APassword: String);
begin
   SMTP := TSMTPSend.Create;

   if AAuthenticate then
   begin
     SMTP.UserName := AUsername;
     SMTP.Password := APassword;
   end;
   SMTP.TargetHost := AHost;
   SMTP.TargetPort := IntToStr(APort);
   SMTP.AutoTLS := (ASecurity = msSTARTTLS);
   SMTP.FullSSL := (ASecurity = msSSLTLS);
   SMTP.Timeout := 10000; // 10 seconds

   if not SMTP.Login then
     raise EMailer.CreateSMTP('SMTP.Login', SMTP);

   if AAuthenticate then
     if not SMTP.AuthDone then
       raise EMailer.Create(sMailerNotAuthenticated);
end;

================================================

Regards,
Denis


On 10/05/2018 14:31, Brian via Lazarus wrote:
> Does anybody have a working example of sending e-mail from a Lazarus
> program through their ISP's mail server (which requires SSL/TLS) that
> they'd be willing to share with me? I've been trying to follow
> Michael's writeup for using Synapse,  I'm getting a timeout error from
> deep within the Synapse code, and I don't know whether it's something
> that I've screwed up or some kind of incompatibility with the mail
> server - my ISP, of course, will only tell me to use Outlook or
> similar. :( If I try to step through with the debugger, I get a socket
> error of 110. The version of Synapse I'm using is (I think) 40.1, at
> least it's the version downloaded via the online package manager.
>
> I'm using Lazarus 1.8.2 and FPC 3.0.4 as downloaded from SourceForge.
>
> Thanks.
>



More information about the Lazarus mailing list