0

im trying to send an email with hotmail sever using delphi
using this code :

SMTP.Username := 'MYEMAIL@hotmail.com';
SMTP.Password := 'PASSWORD';
SMTP.Host := 'smtp.live.com';
SMTP.Port := 25;
SMTP.IOHandler := SSLHandler;
SSLHandler.SSLOptions.Method := sslvTLSV1;
SMTP.UseTLS := utUseImplicitTLS;
SMTP.Connect;

but every time i try to send i get this error: "Socket Error #10060, Connection timed out."

but when i try to send email with google it works fine

SMTP.Username := 'MYEMAIL@hotmail.com';
SMTP.Password := 'PASSWORD';
SMTP.Host := 'smtp.gmail.com';
SMTP.Port := 465;
SMTP.IOHandler := SSLHandler;
SSLHandler.SSLOptions.Method := sslvTLSV1;
SMTP.UseTLS := utUseImplicitTLS;
SMTP.Connect;

any idea why??

Ouerghi Yassine
  • 1,835
  • 7
  • 43
  • 72
  • 4
    Try it with port 587. Also [`this`](http://stackoverflow.com/a/9167630/960757) might be useful to read. – TLama Jul 02 '12 at 16:17
  • 1
    Even port 25 works fine. It is enough if you change the `TIdSMTP.UseTLS` to `utUseExplicitTLS` in your code like Remy suggested in the post linked in my previous comment. – TLama Jul 02 '12 at 19:06
  • 2
    You have to use `utUseExplicitTLS` with ports 25 or 587. You have to use `utUseImplicitTLS` with port 465. If you are using an up-to-date version of Indy 10, it automatically assigns the correct `Port` value for you based on what you assign to `UseTLS`, if you leave the `Port` property set to its default value. – Remy Lebeau Jul 02 '12 at 19:51
  • thx everyone :) it works fine, but why it comes to the junk box? – Ouerghi Yassine Jul 03 '12 at 01:05
  • It works fine for my mailbox (even without adding a spam exception to white list). – TLama Jul 03 '12 at 20:05
  • Just an update: i tried today and for gmail to make it work it is necessry to enable access from less secure apps from: https://www.google.com/settings/security/lesssecureapps – UnDiUdin Aug 01 '16 at 11:26

0 Answers0