Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Email with SSL

edited January 2014 in General
Hello

Using the sample code from the RBuilder WiKi "How To Customize Indy Email
Settings". There appear to be three parameters changes required when
switching between utilizing SSL and not utilizing SSL. These parameters
are:
1) TppSMTPIndy(tempEmail.SMTP).IndySMTP.UseTLS := utUseExplicitTLS;
2) the presence of the ssleay32.dll and the libeay32.dll. Both of which are
located in the application directory.
3) the port utilized.

I have no trouble sending a report via email when I do not use SSL, i.e.
TppSMTPIndy(tempEmail.SMTP).IndySMTP.UseTLS := utNoTLSSupport;
However, when I try to send an email with SSL (making the appropriate
changes mentioned above), I receive a 10061 socket error "connection
refused" error.

Are there parameters (other than the 3 mentioned above) which need to be
changed? Is there something else that I am missing?

TIA

John

Comments

  • edited January 2014
    Hi John,

    In addition to the three steps you provided, you also need to create a
    TIdSSLIOHandlerSocketOpenSSL object to act as the SSL IO Handler and
    give it proper server information (Destination, Host, and Port). This
    then needs to be assigned to the TSMTP.IOHandler property.

    From the RBWiki example:

    var
    ...
    lIOHandler: TIdSSLIOHandlerSocketOpenSSL;
    begin

    ...

    ppReport1.EmailSettings.HostAddress := 'smtp.gmail.com';

    ...

    lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(Self);

    try
    lIOHandler.Destination := 'smtp.gmail.com:587';
    lIOHandler.Host := 'smtp.gmail.com';
    lIOHandler.Port := 587;

    TppSMTPIndy(lEmail.SMTP).IndySMTP.Port := 587;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.IOHandler := lIOHandler;
    TppSMTPIndy(lEmail.SMTP).IndySMTP.UseTLS := utUseExplicitTLS;

    ...

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.