Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TidSMTP through a proxy


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jul 24, 2017 10:45 AM Last Post By: Remy Lebeau (Te...
Jorge Luis Rodr...

Posts: 1
Registered: 1/3/10
TidSMTP through a proxy  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 17, 2017 12:47 PM
Hello

I made an application with Delphi Berlin that sends mails with attachments.

It works fine if I'm connected to the internet without a proxy, but if I connect through a proxy it does not work.

I'm using the Indy TidSMTP component

How do I have to send mail with TidSMPT through a proxy?

Without a proxy, the mails are sent without problem, but with proxy I can not make it work.

In the form I have the following Indy components:
- TidSMTP named idSMTP1
- TidMessage named idMessage1
- TidSSLIOHandlerSocketOPenSSL named handler1
- TidConnectThroughHttpProxy named HTTP1

This is the code for the onClick event of the submit button:

IdSMTP1.AuthType := TIdSMTPAuthenticationType.satDefault;
 
  HTTP1.Host := '10.99.8.2';  // proxy server ip
  HTTP1.Port := 8080; // proxy port number
 
  handler1.TransparentProxy := HTTP1;
 
  IdSMTP1.Username := edUser.Text;
  IdSMTP1.Password := edPassword.Text;
 
  IdSMTP1.Host := edHost.Text;
  IdSMTP1.Port := 587;
  sAnexo := 'c:\file.pdf';
  if FileExists(sAnexo) then
    begin
      TIdAttachmentFile.Create(IdMessage1.MessageParts, sAnexo);
    end;
 
  IdSMTP1.Connect;
 
  try
    IdMessage1.From.Address := edFrom.Text;
    IdMessage1.Recipients.EMailAddresses := edTo.Text;
    IdMessage1.CCList.EMailAddresses := edCC.Text;
    IdMessage1.BCCList.EMailAddresses := edBCC.Text;
    IdMessage1.Subject := edSubject.Text;
    IdMessage1.Body := edContent.Lines;
    idSMTP1.Send(idMessage1);
 
  finally
    IdSMTP1.Disconnect;
  end;
  ShowMessage('Mail send OK!.');


If someone has an example in delphi, I will thank you.

Thank you.

Edited by: Jorge Luis Rodriguez on Jul 17, 2017 12:47 PM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TidSMTP through a proxy [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 24, 2017 10:45 AM   in response to: Jorge Luis Rodr... in response to: Jorge Luis Rodr...
Jorge Luis Rodriguez wrote:

It works fine if I'm connected to the internet without a proxy, but if
I connect through a proxy it does not work.

In what way exactly does it not work? Are you getting any errors?

- TidSMTP named idSMTP1

What are you settings its UseTLS property to?

- TidConnectThroughHttpProxy named HTTP1

Your code is setting its Host and Port properties, but are you also
setting its Enabled property to true?

handler1.TransparentProxy := HTTP1;

Are you assigning the SSLHandler to the TIdSMTP.IOHandler property?

IdSMTP1.Host := edHost.Text;

IdSMTP1.Port := 587;

That implies that you are setting the TIdSMTP.UseTLS property to
utUseExplicitTLs, is that right?

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02