Recent

Author Topic: How Send Email (Gmail, Hotmail, Yahoo)  (Read 23789 times)

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
How Send Email (Gmail, Hotmail, Yahoo)
« on: May 30, 2016, 04:25:53 pm »
hello my friends, as I send an email from my app.   :)
« Last Edit: May 30, 2016, 07:35:22 pm by Ericktux »

eric

  • Sr. Member
  • ****
  • Posts: 267
Re: Send Email (Gmail, Hotmail, Yahoo)
« Reply #1 on: May 30, 2016, 07:33:27 pm »
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

  • Sr. Member
  • ****
  • Posts: 345
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #2 on: May 30, 2016, 07:38:38 pm »
Hi eric, thank for you answer, effectively is a question  :)

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #3 on: May 31, 2016, 04:00:41 pm »
Hi, I was testing the example (xmailer) but not happen nothing, this is mi code:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. var
  3.   Mail: TSendMail;
  4. begin
  5. try
  6.   try
  7.     // Mail
  8.     Mail := TSendMail.Create;
  9.     Mail.Sender := 'ericktux <ericktux@hotmail.com>';
  10.     Mail.Receivers.Add('client_01@hotmail.com');
  11.     Mail.Subject := 'hello';
  12.     Mail.Message.Add('how are you');
  13.     // SMTP
  14.     Mail.Smtp.UserName := 'ericktux@hotmail.com';
  15.     Mail.Smtp.Password := 'mypasswords';
  16.     Mail.Smtp.Host := 'smtp.live.com';
  17.     Mail.Smtp.Port := '25';
  18.     Mail.Smtp.SSL := True;
  19.     Mail.Smtp.TLS := True;
  20.     Mail.Send;
  21.   except
  22.     on E:Exception do
  23.     ShowMessage('error');
  24.   end;
  25.   finally
  26.     Mail.Free;
  27.   end;
  28. end;

any help  :(

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #4 on: May 31, 2016, 04:18:54 pm »
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/
« Last Edit: May 31, 2016, 04:22:42 pm by rvk »

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #5 on: May 31, 2016, 04:39:15 pm »
Thank you rvk, i put 587, but i get the same error message  :( :(
Adjunt the image of my files.

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #6 on: May 31, 2016, 04:42:38 pm »
Adjunt 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

  • Hero Member
  • *****
  • Posts: 6163
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #7 on: May 31, 2016, 04:51:36 pm »
Thank you rvk, i put 587, but i get the same error message  :( :(
O, and you still didn't mention which error.

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #8 on: May 31, 2016, 04:55:16 pm »
I think I found it.
You need to add this:
Code: Pascal  [Select][+][-]
  1. Mail.Smtp.Port := '587'; // <-- use this port
  2. Mail.Smtp.FullSSL := false;
Then it worked for me with smtp.live.com

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #9 on: May 31, 2016, 05:47:33 pm »
Thank You friend rvk, now works  :D :D
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][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, XMailer;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.     { private declarations }
  19.   public
  20.     { public declarations }
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. var
  34.   Mail: TSendMail;
  35. begin
  36. Mail := TSendMail.Create;
  37. try
  38.     // Mail
  39.     Mail.Sender := 'ericktux <ericktux@hotmail.com>';
  40.     Mail.Receivers.Add('client_01@hotmail.com');
  41.     Mail.Subject := 'Hello';
  42.     Mail.Message.Add('How are you');
  43.     mail.Attachments.Add('C:\saludos.log');  // for send files, optional
  44.     // SMTP
  45.     Mail.Smtp.UserName := 'ericktux@hotmail.com';
  46.     Mail.Smtp.Password := 'mypassword';
  47.     Mail.Smtp.Host := 'smtp.live.com';
  48.     Mail.Smtp.Port := '587';
  49.     //Mail.Smtp.SSL := True;
  50.     mail.Smtp.FullSSL:=false;  // thanks rvk
  51.     Mail.Smtp.TLS := True;
  52.     Mail.Send;
  53.     ShowMessage('SUCCESS :) ');
  54.   {except
  55.     on E:Exception do
  56.  
  57.   end;}
  58.   finally
  59.     Mail.Free;
  60.   end;
  61. end;
  62. end.


Works for Hotmail, Gmail and Yahoo  :D :D :D

luk2009

  • Jr. Member
  • **
  • Posts: 51
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #10 on: May 31, 2018, 05:07:30 am »
 https://github.com/silvioprog/xmailer this link not working.

anybody have a copy?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #11 on: May 31, 2018, 09:27:46 am »
This seems to be a clone: https://github.com/MFernstrom/xmailer

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #12 on: May 31, 2018, 09:34:26 am »
Lazarus 2.0.2 64b on Debian LXDE 10

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #13 on: May 31, 2018, 10:52:09 am »
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/xmailer
regards
Andreas

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: How Send Email (Gmail, Hotmail, Yahoo)
« Reply #14 on: May 31, 2018, 10:56:08 am »
XMailer is also available directly within Lazarus via OnlinePackageManager.

 

TinyPortal © 2005-2018