Working code to send email Yahoo to Gmail lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Bandy · 2022-04-03 17:32 Hello, I need working code to send email Yahoo to Gmail. Thank you. ---------------------------------------------------------------------- AlexTP · 2022-04-03 17:54 https://wiki.freepascal.org/Synapse_-_Email_Examples ---------------------------------------------------------------------- alpine · 2022-04-03 22:22 You can look also here: https://forum.lazarus.freepascal.org/index.php/topic,58764.0.html ---------------------------------------------------------------------- Bandy · 2022-04-04 07:34 I don't know why, but none of the example above don't work. Please help me. ---------------------------------------------------------------------- Bandy · 2022-04-04 08:50 I need WORKING WORKING WORKING code to send email from Yahoo to Gmail. Please help me. Thank you. ---------------------------------------------------------------------- rvk · 2022-04-04 08:59 Quote from: Bandy on April 04, 2022, 10:50:46 amI need WORKING WORKING WORKING code to send email from Yahoo to Gmail. Maybe you can explain WHAT is not working. Error messages, code you really typed (with password crossed out), Error messages... O, and I forgot Error messages. Just shouting it doesn't work isn't helpful. ---------------------------------------------------------------------- Bandy · 2022-04-04 15:15 Quote from: rvk on April 04, 2022, 10:59:18 amQuote from: Bandy on April 04, 2022, 10:50:46 amI need WORKING WORKING WORKING code to send email from Yahoo to Gmail. Maybe you can explain WHAT is not working. Error messages, code you really typed (with password crossed out), Error messages... O, and I forgot Error messages. Just shouting it doesn't work isn't helpful. The code from AlexTP returns no errors, everything in typed correctly, but the email from Yahoo to Gmail is NOT sended. ---------------------------------------------------------------------- rvk · 2022-04-04 15:20 Does it go into the if statement of SMTP.Login? Put a showmessage or something within to see if it comes to that point. Did you put the openssl dlls in your exe directory? Show your code calling to that function (with passwd crossed out). ---------------------------------------------------------------------- Bandy · 2022-04-04 15:26 I have openssl dlls in my exe directory. Result is false. Maybe Indy will work somehow. ---------------------------------------------------------------------- rvk · 2022-04-04 15:39 Quote from: Bandy on April 04, 2022, 05:26:56 pmResult is false. I asked if it got past the SMTP.Login line? Result was set in the beginning so is the Result of SMTP.MailData etc false or the complete SendMail function result? Please be more elaborate. If .Login is true you can split the maildata, mailfrom and mailto to see which one returns false. ---------------------------------------------------------------------- Bandy · 2022-04-04 15:43 Yes, it got past the SMTP.Login line. ---------------------------------------------------------------------- Bandy · 2022-04-04 15:51 Every individual function: MailFrom, MailTo, MailData returns False. ---------------------------------------------------------------------- Bandy · 2022-04-04 15:52 Why do I need all three functions? ---------------------------------------------------------------------- bobby100 · 2022-04-04 16:00 Bandy, take a look here: https://sourceforge.net/projects/smtp-test-suite/ Start the smtp-test-client and test your login etc. When you have found which settings are working for you, take a look at the source-code of the smtp-test-client and use it with your settings (hard-code your settings if you like so). Sending an email is not an one-shot process. There is some more handshaking between the server and the client. ---------------------------------------------------------------------- Bandy · 2022-04-04 16:07 Maybe Indy will work somehow. ---------------------------------------------------------------------- rvk · 2022-04-04 16:43 Quote from: Bandy on April 04, 2022, 06:07:32 pmMaybe Indy will work somehow. That won't work either. You are probably just using the wrong authentication data. For example. You can check this with 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 Showmessage(SMTP.FullResult.Text);after the SMTP.MailFrom() line. If it gives you something like: Quote530-5.7.0 Authentication Required. Learn more at 530 5.7.0  https://support.google.com/mail/?p=WantAuthError xxxxxx - gsmtp you are using your normal gmail login-data and you can't do that. That won't work in indy either. You could create a app-password and use that. Goto https://myaccount.google.com/security and create an App password for E-mail / Windows-computer Use that with your username and this function will work (if you called it correctly, but you still haven't shown that). Edit: oops, your issue was with yahoo to gmail. Not sure if yahoo also has app passwords but you can still look at the fullresult text to see the problem. Edit #2: yeah. Yahoo also needs app passwords. https://help.yahoo.com/kb/SLN15241.html ---------------------------------------------------------------------- bobby100 · 2022-04-04 16:46 Bandy, both Indy and Synapse are working. Don't expect anyone here to register a Yahoo account just to test it for you. I gave you a link in my previous post for a program (it uses Synapse). Download it, unpack and load the file that I attached to this message, fill your password for your Yahoo account, click on 'Test' and post the log here (delete your password from the log before posting if it is visible there). After that, I can help you further. ---------------------------------------------------------------------- Bandy · 2022-04-04 16:58 Quote from: bobby100 on April 04, 2022, 06:46:18 pmBandy, both Indy and Synapse are working. Don't expect anyone here to register a Yahoo account just to test it for you. I gave you a link in my previous post for a program (it uses Synapse). Download it, unpack and load the file that I attached to this message, fill your password for your Yahoo account, click on 'Test' and post the log here (delete your password from the log before posting if it is visible there). After that, I can help you further. SMTP Login      <- 220 smtp.mail.yahoo.com ESMTP ready      -> EHLO smtp.mail.yahoo.com      <- 250-kubenode505.mail-prod1.omega.ir2.yahoo.com Hello smtp.mail.yahoo.com [178.138.35.169])         250-PIPELINING         250-ENHANCEDSTATUSCODES         250-8BITMIME         250-SIZE 41697280      <- 535 5.7.0 (#AUTH005) Too many bad auth attempts.      -> AUTH LOGIN      <- SMTP Logout      -> QUIT SMTP STATUS: Logout:???-Other undefined Status OK! ---------------------------------------------------------------------- bobby100 · 2022-04-04 17:00 It seems that your Yahoo account is suspended because of too many login failures. Update: Please delete the text after the AUTH PLAIN from your log (your previous message). It is your hashed password. Don't leave it here on the forum. ---------------------------------------------------------------------- rvk · 2022-04-04 17:03 And remove the text after auth plain in your reply because it has your email and password encoded. (And change your yahoo password for good measure.) ---------------------------------------------------------------------- Bandy · 2022-04-04 17:06 Quote from: rvk on April 04, 2022, 07:03:54 pmAnd remove the text after auth plain in your reply because it has your email and password encoded. (And change your yahoo password for good measure.) No, my Yahoo account is working fine on my laptop browser and my Android phone. ---------------------------------------------------------------------- rvk · 2022-04-04 17:08 Quote from: Bandy on April 04, 2022, 07:06:43 pmNo, my Yahoo account is working fine on my laptop browser and my Android phone. Try to create an app password (from the faq posted). https://help.yahoo.com/kb/SLN15241.html ---------------------------------------------------------------------- bobby100 · 2022-04-04 17:12 https://support.cdesoftware.com/kb/a1909/535-5_7_0-auth005-too-many- bad-auth-attempts-error-when-trying-to-send-email_.aspx It is Yahoo that does not allow 3rd party apps to access it. You must adjust your Yahoo settings. The same goes for Gmail. https://www.google.com/search?client=firefox-b- d&q=yahoo+mail+535+5.7.0+%28%23AUTH005%29+Too+many+bad+auth+attempts. Edit#2: or try what rvk suggested, with generated passwords. I didn't know such a thing existed. @rvk - thank you for the info. I have always modified the Gmail account settings to allow 3rd party apps (less secure). ---------------------------------------------------------------------- Bandy · 2022-04-04 17:24 Quote from: rvk on April 04, 2022, 07:08:48 pmQuote from: Bandy on April 04, 2022, 07:06:43 pmNo, my Yahoo account is working fine on my laptop browser and my Android phone. Try to create an app password (from the faq posted). https://help.yahoo.com/kb/SLN15241.html I created the app password. ---------------------------------------------------------------------- Bandy · 2022-04-04 17:37 What should I do next, please? ---------------------------------------------------------------------- rvk · 2022-04-04 17:39 Quote from: Bandy on April 04, 2022, 07:37:56 pmWhat should I do next, please? Dud you ran bobby's code with that app password? If it still gives you the same error, did you create a new app password? ---------------------------------------------------------------------- Bandy · 2022-04-04 17:49 Quote from: rvk on April 04, 2022, 07:39:47 pmQuote from: Bandy on April 04, 2022, 07:37:56 pmWhat should I do next, please? Dud you ran bobby's code with that app password? If it still gives you the same error, did you create a new app password? I run smtp_test_client.exe and Too many bad auth attempts is still displayed. I created a new app password. ---------------------------------------------------------------------- bobby100 · 2022-04-04 17:50 You did put the generated app password instead of your personal password in the smtp-test-client and it did't work? ---------------------------------------------------------------------- rvk · 2022-04-04 17:53 And did you also set the option to allow apps to use less secure sign in? (This is a separate option) As stated by the link bobby already gave you: QuoteTo resolve, go to https://login.yahoo.com/account/security and then enable the option to allow apps that use less secure sign in. ---------------------------------------------------------------------- Bandy · 2022-04-04 17:57 Quote from: bobby100 on April 04, 2022, 07:50:43 pmYou did put the generated app password instead of your personal password in the smtp- test-client and it did't work? Yes. ---------------------------------------------------------------------- Bandy · 2022-04-04 17:59 Quote from: rvk on April 04, 2022, 07:53:18 pmAnd did you also set the option to allow apps to use less secure sign in? (This is a separate option) As stated by the link bobby already gave you: QuoteTo resolve, go to https://login.yahoo.com/account/security and then enable the option to allow apps that use less secure sign in.I don't see/have the option to allow apps that use less secure sign in. ---------------------------------------------------------------------- bobby100 · 2022-04-04 18:15 I did a little research on the net, and it seems that Yahoo (since 20.10.2020) won't allow third-party apps if they are not using Oauth2 authentication. I can't help you here, I have no clue about Oauth2. https://support.mozilla.org/en-US/kb/thunderbird-and-yahoo ---------------------------------------------------------------------- Bandy · 2022-04-04 18:37 Please help me... ---------------------------------------------------------------------- bobby100 · 2022-04-04 18:45 You'll need to wait for rvk. I was ready to help, but this goes behind my knowledge. ---------------------------------------------------------------------- rvk · 2022-04-04 19:42 Quote from: bobby100 on April 04, 2022, 08:15:52 pmI did a little research on the net, and it seems that Yahoo (since 20.10.2020) won't allow third-party apps if they are not using Oauth2 authentication.I think that's when they implemented the app password mechanisme (instead of the yahoo password). I tried with my old account but I got a lot of troubles signing in. one time it worked and created an app password and with a few attempts for port I also got the '535 5.7.0 (#AUTH005) Too many bad auth attempts.'. I wanted to create a new app password but now I can't login (it gives me Uh-oh... We can’t sign you in right now. and another time a timeout error). It seems yahoo is really really unstable. If it would really need OAuth2 then I can't help either because I only have experience with the Google OAuth2. (but I still think app password should work) Edit: Can login again and a new app password still fives '535 5.7.0 (#AUTH005) Too many bad auth attempts.' inside TSMTPSend.AuthPlain. Edit 2: Aaaaargh. Now I can get a mail out. With the exact code from the start page and a new fresh app password. So, no, OAuth2 isn't needed. But I wouldn't rely on yahoo always working flawlessly with the issues they are having. 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 if SendMail('my_username_without_yahoo.com', 'app_password', 'my_email@yahoo.com', 'user@domain.com', 'smtp.mail.yahoo.com', '465', 'Subject: test' + #13#10#13#10 + 'test') then  Memo1.Lines.Add('success')else  Memo1.Lines.Add('error'); Edit 3: Now the other older app password works also again. So maybe it was a temporary issue with yahoo. (hence my reluctance if you want to use this in production code) ---------------------------------------------------------------------- Bandy · 2022-04-05 07:26 And what is the complete working code for sending email from Yahoo to Gmail, please rvk? ---------------------------------------------------------------------- rvk · 2022-04-05 07:32 Quote from: Bandy on April 05, 2022, 09:26:32 amAnd what is the complete working code for sending email from Yahoo to Gmail, please rvk? The exact code from the wiki page linked on the first page in this topic. Call-code I showed you in my last post. So 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 uses  ..., smtpsend, ssl_openssl; function SendMail(const User, Password, MailFrom, MailTo, SMTPHost, SMTPPort, MailData: string): Boolean;var  SMTP: TSMTPSend;  sl:TStringList;begin  Result:=False;  SMTP:=TSMTPSend.Create;  sl:=TStringList.Create;  try    sl.text:=Maildata;    SMTP.UserName:=User;    SMTP.Password:=Password;    SMTP.TargetHost:=SMTPHost;    SMTP.TargetPort:=SMTPPort;    SMTP.AutoTLS:=true;    if SMTPPort<> '25' then      SMTP.FullSSL:=true;    if SMTP.Login then    begin    Result:=SMTP.MailFrom(MailFrom, Length(MailData)) and         SMTP.MailTo(MailTo) and         SMTP.MailData(sl);      SMTP.Logout;    end;  finally    SMTP.Free;    sl.Free;  end;end; // ... if SendMail('my_username_without_yahoo.com', 'app_password', 'my_email@yahoo.com', 'user@domain.com', 'smtp.mail.yahoo.com', '465', 'Subject: test' + #13#10#13#10 + 'test') then  Memo1.Lines.Add('success')else  Memo1.Lines.Add('error'); Edit: Just ran the code again and still 'success' for me. Although now I receive them with a delay of a few minutes. (Also make sure your 'data' is well formed with subject, to etc because otherwise it could be seen as spam. The one liner worked for me but spamassassin did add some score to it.) ---------------------------------------------------------------------- Bandy · 2022-04-05 08:52 Quote from: rvk on April 05, 2022, 09:32:07 amQuote from: Bandy on April 05, 2022, 09:26:32 amAnd what is the complete working code for sending email from Yahoo to Gmail, please rvk? The exact code from the wiki page linked on the first page in this topic. Call-code I showed you in my last post. So 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 uses  ..., smtpsend, ssl_openssl; function SendMail(const User, Password, MailFrom, MailTo, SMTPHost, SMTPPort, MailData: string): Boolean;var  SMTP: TSMTPSend;  sl:TStringList;begin  Result:=False;  SMTP:=TSMTPSend.Create;  sl:=TStringList.Create;  try    sl.text:=Maildata;    SMTP.UserName:=User;    SMTP.Password:=Password;    SMTP.TargetHost:=SMTPHost;    SMTP.TargetPort:=SMTPPort;    SMTP.AutoTLS:=true;    if SMTPPort<> '25' then      SMTP.FullSSL:=true;    if SMTP.Login then    begin    Result:=SMTP.MailFrom(MailFrom, Length(MailData)) and         SMTP.MailTo(MailTo) and         SMTP.MailData(sl);      SMTP.Logout;    end;  finally    SMTP.Free;    sl.Free;  end;end; // ... if SendMail('my_username_without_yahoo.com', 'app_password', 'my_email@yahoo.com', 'user@domain.com', 'smtp.mail.yahoo.com', '465', 'Subject: test' + #13#10#13#10 + 'test') then  Memo1.Lines.Add('success')else  Memo1.Lines.Add('error'); Edit: Just ran the code again and still 'success' for me. Although now I receive them with a delay of a few minutes. (Also make sure your 'data' is well formed with subject, to etc because otherwise it could be seen as spam. The one liner worked for me but spamassassin did add some score to it.) It works fine, thanks rvk!!! ---------------------------------------------------------------------- kiyo · 2025-02-01 12:13 Can you send a Mail from YahooMail to Gmail? I use a Windows PC. I can send emails from Yahoo Mail to Gmail using Thunderbird. , so I think my ID and password are correct. Yahoo Mail's security policy has changed so it doesn't work anymore. How can I fix this? ---------------------------------------------------------------------- rvk · 2025-02-01 13:33 Quote from: kiyo on February 01, 2025, 01:13:41 pmYahoo Mail's security policy has changed so it doesn't work anymore. The code above still works correctly. BUT... you do need to create a complete DATA segment with all mail elements. That means you need to have the From: line in there too. The To: isn't strictly needed (I noticed) but it's best to also include it. So the data needs to look like: Code: [Select]From: my_email@yahoo.com To: user@domain.com Subject: test body of mail multiple lines For me these are the changes: 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 var  sl: TStringList;begin  sl := TStringList.Create;  try    sl.Add('From: my_email@yahoo.com');    sl.Add('To: user@domain.com');    sl.Add('Subject: Test');    sl.Add('');    sl.Add('');    sl.Add('body of mail');    sl.Add('multiple lines');    if SendMail('my_username_without_yahoo.com', 'app_password', 'my_email@yahoo.com', 'user@domain.com', 'smtp.mail.yahoo.com', '465', sl.Text)      Writeln('success')    else      Writeln('error');  finally    sl.Free;  end;  readln;end. Don't forget that you can't use your own password but need to make an APP PASSWORD in security settings to use in the mail line. https://login.yahoo.com/myaccount/security/ ---------------------------------------------------------------------- kiyo · 2025-02-01 21:31 It worked, thank you. yahoo app password is not supported here in Japan. So I can't generate it. ---------------------------------------------------------------------- rvk · 2025-02-01 21:55 Quote from: kiyo on February 01, 2025, 10:31:02 pmIt worked, thank you. yahoo app password is not supported here in Japan. So I can't generate it. Ha, ok. So in Japan it still works with your normal password. Glad you got it working. ---------------------------------------------------------------------- Bandy · 2025-06-27 14:06 The code from Bandy's (my) post on: April 05, 2022, 10:52:37 am, where I say: "It works fine, thanks rvk!!!" is not doing the login anymore at "if SMTP.Login then" line. This is the code from my post on: April 05, 2022, 10:52:37 am: uses   ..., smtpsend, ssl_openssl; function SendMail(const User, Password, MailFrom, MailTo, SMTPHost, SMTPPort, MailData: string): Boolean; var   SMTP: TSMTPSend;   sl:TStringList; begin   Result:=False;   SMTP:=TSMTPSend.Create;   sl:=TStringList.Create;   try     sl.text:=Maildata;     SMTP.UserName:=User;     SMTP.Password:=Password;     SMTP.TargetHost:=SMTPHost;     SMTP.TargetPort:=SMTPPort;     SMTP.AutoTLS:=true;     if SMTPPort<> '25' then       SMTP.FullSSL:=true;     if SMTP.Login then {here the login is not done ok and the mail is not send anymore}     begin       Result:=SMTP.MailFrom(MailFrom, Length(MailData)) and          SMTP.MailTo(MailTo) and          SMTP.MailData(sl);       SMTP.Logout;     end;   finally     SMTP.Free;     sl.Free;   end; end; // ... if SendMail('my_username_without_yahoo.com', 'app_password', 'my_email@yahoo.com', 'user@domain.com', 'smtp.mail.yahoo.com', '465', 'Subject: test' + #13#10#13#10 + 'test') then   Memo1.Lines.Add('success') else   Memo1.Lines.Add('error'); I changed the app password, but the mail still doesn't send. Please help!!! ---------------------------------------------------------------------- gues1 · 2025-06-27 16:53 Quote from: Bandy on June 27, 2025, 04:06:23 pmI changed the app password, but the mail still doesn't send. Please help!!! May be you must do what @rvk said: Quote from: rvk on February 01, 2025, 02:33:13 pmDon't forget that you can't use your own password but need to make an APP PASSWORD in security settings to use in the mail line. https://login.yahoo.com/myaccount/security/ If it doesn't works, try to use TLS with port 587 ---------------------------------------------------------------------- rvk · 2025-06-27 21:52 Quote from: Bandy on June 27, 2025, 04:06:23 pmThe code from Bandy's (my) post on: April 05, 2022, 10:52:37 am, where I say: "It works fine, thanks rvk!!!" is not doing the login anymore at "if SMTP.Login then" line. The code still works fine. The login also works. If the login doesn't work, you might have the wrong OpenSSL dll's in your exe directory. Make sure they are correct. You can change the following: 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       if SMTP.Login then      begin        Writeln('Login ok');        Result := SMTP.MailFrom(MailFrom, Length(MailData));        Writeln('MailFrom ok ', Ord(Result), ' Result: ', SMTP.FullResult.Text);        if Result then Result := SMTP.MailTo(MailTo);        Writeln('MailTo ok ', Ord(Result), ' Result: ', SMTP.FullResult.Text);        if Result then Result := SMTP.MailData(sl);        Writeln('MailData ok ', Ord(Result), ' Result: ', SMTP.FullResult.Text);        SMTP.Logout;      Writeln('Logout ok ', ' Result: ', SMTP.FullResult.Text);      end; That way, you see the result with each step. When OpenSSL is included, the login should work fine. BUT... you end up with another problem... If you use above code you'll get: QuoteLogin ok MailFrom ok 1 Result: 250 2.1.0 Sender OK MailTo ok 1 Result: 250 2.1.5 Recipient OK MailData ok 0 Result: 554 6.6.0 Error sending message for delivery. Logout ok  Result: 221 Service Closing transmission error And that's because of the following... did you read my previous post? (quoted below) You really need to create a complete DATA segment including FROM, TO, SUBJECT and the message itself. Yahoo cracked down on just sending a bare minimum and the things above really need to be there. In your code you just have SUBJECT and one line. That's not enhough. (You can use code below to create a more complete DATA segment for your message) Quote from: rvk on February 01, 2025, 02:33:13 pmQuote from: kiyo on February 01, 2025, 01:13:41 pmYahoo Mail's security policy has changed so it doesn't work anymore. The code above still works correctly. BUT... you do need to create a complete DATA segment with all mail elements. That means you need to have the From: line in there too. The To: isn't strictly needed (I noticed) but it's best to also include it. So the data needs to look like: Code: [Select]From: my_email@yahoo.com To: user@domain.com Subject: test body of mail multiple lines For me these are the changes: 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 var  sl: TStringList;begin  sl := TStringList.Create;  try    sl.Add('From: my_email@yahoo.com');    sl.Add('To: user@domain.com');    sl.Add('Subject: Test');    sl.Add('');    sl.Add('');    sl.Add('body of mail');    sl.Add('multiple lines');    if SendMail('my_username_without_yahoo.com', 'app_password', 'my_email@yahoo.com', 'user@domain.com', 'smtp.mail.yahoo.com', '465', sl.Text)      Writeln('success')    else      Writeln('error');  finally    sl.Free;  end;  readln;end. Still works (just tested it). ---------------------------------------------------------------------- Bandy · 2025-06-28 12:42 I don't have OpenSSL dll's in my exe directory. I didn't haved them at all and the code was working ok. From where do I get OpenSSL dll's? ---------------------------------------------------------------------- rvk · 2025-06-28 15:44 Quote from: Bandy on June 28, 2025, 02:42:17 pmI don't have OpenSSL dll's in my exe directory. I didn't haved them at all and the code was working ok. From where do I get OpenSSL dll's? Maybe there was an open SSL dll in your search path under Windows. But if they are not installed you are better of just copying them into your .exe directory. Take the latest from the correct 64 bit version here https://github.com/IndySockets/OpenSSL-Binaries For example openssl-1.0.2u-x64_86-win64.zip for 64 bit application. You can search for others (like 1.1 and 3.x versions) but these should work fine for Yahoo for now. ---------------------------------------------------------------------- Bandy · 2025-06-29 09:30 I put OpenSSL dll's from your link to my .exe folder: libeay32.dll and ssleay32.dll. ---------------------------------------------------------------------- Bandy · 2025-06-29 10:11 And it works! The mail is send! Thank you, rvk! ---------------------------------------------------------------------- Bandy · 2025-06-29 10:50 It's possible to send email directly from my .exe to any email address (let's say to Gmail)? I mean to have a mail server into my .exe? I hope I was clear. ---------------------------------------------------------------------- rvk · 2025-06-29 11:04 Quote from: Bandy on June 29, 2025, 12:50:18 pmIt's possible to send email directly from my .exe to any email address (let's say to Gmail)? I mean to have a mail server into my .exe? I hope I was clear. It’s possible in theory. In practice, it’s not. Most providers have blocked outgoing port 25 to limit the risk of viruses doing exactly what you want to do. And without port 25 you can't reach the server you need to deliver mail. So you are stuck using a third party SMTP server for this. ---------------------------------------------------------------------- Bandy · 2025-06-29 11:26 Can you post a link with the newest OpenSSL dll's: libeay32.dll and ssleay32.dll? ---------------------------------------------------------------------- Bandy · 2025-06-29 11:42 If I want to attach a file or two to email, how the code should be modified? ---------------------------------------------------------------------- dsiders · 2025-06-29 14:11 Quote from: Bandy on June 29, 2025, 01:26:38 pmCan you post a link with the newest OpenSSL dll's: libeay32.dll and ssleay32.dll? In current SSL versions, those files are called libcrypto and libssl. Since 2018 (?). ---------------------------------------------------------------------- Bandy · 2025-06-29 16:57 I think you understanded wrong, dsiders. rvk posted https://github.com/IndySockets/OpenSSL-Binaries with openssl-1.0.2u-x64_86-win64.zip, ver. 1.0.2. I was asking for a link with the newest version for OpenSSL. ---------------------------------------------------------------------- Bandy · 2025-06-29 17:01 For rvk please: 1. Can you post a link with the newest OpenSSL dll's: libeay32.dll and ssleay32.dll? 2. If I want to attach a file or two to email, how the code should be modified? ---------------------------------------------------------------------- rvk · 2025-06-29 17:01 Quote from: Bandy on June 29, 2025, 01:26:38 pmCan you post a link with the newest OpenSSL dll's: libeay32.dll and ssleay32.dll? The OpenSSL 3 dll's are in there too: https://github.com/IndySockets/OpenSSL- Binaries/tree/master/openssl-3_x If you are going to use those, you need to use ssl_openssl3 instead of ssl_openssl in your uses clause. As dsiders stated... the version 3 has libcrypto-3-x64.dll and libssl-3-x64.dll. The other files are for OpenSSL 1.0.2 which isn't updated anymore (and the latest are in that directory). Quote from: Bandy on June 29, 2025, 01:42:49 pmIf I want to attach a file or two to email, how the code should be modified? In that case... you need to construct the complete DATA segment including the attachments. The easiest way to do that is using mimemess and mimepart from Synapse. Here is a function to create a complete EML part (EML is the mail which you can put in the DATA part). It's also usable for directly opening in Thunderbird and Outlook program. 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 uses mimemess, mimepart, synachar; function GetEMLString(const MailFrom, MailTo, Subject: string;  const MailData: TStrings; Attachments: TStrings): string;var  Mime: TMimemess;  P: TMimePart;  S: string;begin  Mime := TMimeMess.Create;  try    //Build a header    Mime.Header.CharsetCode := UTF_8;    Mime.header.From := MailFrom;    Mime.Header.ToList.Add(MailTo);    Mime.Header.Subject := Subject;    // Create a MultiPart part    P := Mime.AddPartMultipart('mixed', nil);    // Add as first part the mail text    Mime.AddPartTextEx(MailData, P, UTF_8, True, ME_8BIT);    // Add all attachments:    for S in Attachments do Mime.AddPartBinaryFromFile(S, P);    // Compose message    Mime.EncodeMessage;    Result := Mime.Lines.Text;  finally    Mime.Free;  end;end;  procedure TForm1.Button1Click(Sender: TObject);var  Files: TStringList;  Content: TStringList;begin  Files := TStringList.Create;  Content := TStringList.Create;  try    Content.Add('This is the body.');    Content.Add('Files are attached.');    Files.Add('c:\temp\test2.bmp');    Memo1.Lines.Text := GetEMLString('test_from', 'test_to', 'subject', Content, Files);    // here you can use the data for sending the mail...  finally    Content.Free;    Files.Free;  end;end;