title: Send e-mail using gmail and Indy
body: <p>I am trying to send an e-mail from Delphi using gmail.
  I have Indy 10.5.9.0 and Delphi XE3.</p>
  
  <p>I got example code from:
  <a href="http://www.andrecelestino.com/delphi-xe-envio-de-e-mail-com-componentes-indy/" rel="noreferrer">http://www.andrecelestino.com/delphi-xe-envio-de-e-mail-com-componentes-indy/</a></p>
  
  <p>I also tried other example codes but with same results.</p>
  
  <p>I have libeay32.dll and ssleay32.dll from here:
  <a href="http://www.andrecelestino.com/wp-content/files/DLLs-SSL-DelphiXE.rar" rel="noreferrer">http://www.andrecelestino.com/wp-content/files/DLLs-SSL-DelphiXE.rar</a>
  but I also tried:
  <a href="http://indy.fulgan.com/SSL/openssl-1.0.2d-i386-win32.zip" rel="noreferrer">http://indy.fulgan.com/SSL/openssl-1.0.2d-i386-win32.zip</a>
  with no luck.</p>
  
  <p>My code (FULL):</p>
  
  <pre><code>uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ComCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
    IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdMessage,
    IdSMTP, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdText;
  
  
  
  
  
  
  procedure TForm1.Button1Click(Sender: TObject);
  var
    // variáveis e objetos necessários para o envio
    IdSSLIOHandlerSocket: TIdSSLIOHandlerSocketOpenSSL;
    IdSMTP: TIdSMTP;
    IdMessage: TIdMessage;
    IdText: TIdText;
    sAnexo: string;
  begin
    // instanciação dos objetos
    IdSSLIOHandlerSocket := TIdSSLIOHandlerSocketOpenSSL.Create(Self);
    IdSMTP := TIdSMTP.Create(Self);
    IdMessage := TIdMessage.Create(Self);
  
    try
      // Configuração do protocolo SSL (TIdSSLIOHandlerSocketOpenSSL)
      IdSSLIOHandlerSocket.SSLOptions.Method := sslvSSLv23;
      IdSSLIOHandlerSocket.SSLOptions.Mode := sslmClient;
  
      // Configuração do servidor SMTP (TIdSMTP)
      IdSMTP.IOHandler := IdSSLIOHandlerSocket;
      IdSMTP.UseTLS := utUseImplicitTLS;
      IdSMTP.AuthType := satDefault;
      IdSMTP.Port := 465;
      IdSMTP.Host := 'smtp.gmail.com';
      IdSMTP.Username := 'MYLOGIN@gmail.com';
      IdSMTP.Password := 'MYPASS';
  
      // Configuração da mensagem (TIdMessage)
      IdMessage.From.Address := 'MYLOGIN@gmail.com';
      IdMessage.From.Name := 'John Smith';
      IdMessage.ReplyTo.EMailAddresses := IdMessage.From.Address;
      IdMessage.Recipients.Add.Text := 'receiver@example.com';
      IdMessage.Subject := 'Hello World';
      IdMessage.Encoding := meMIME;
  
      // Configuração do corpo do email (TIdText)
      IdText := TIdText.Create(IdMessage.MessageParts);
      IdText.Body.Add('The body of the e-mail goes here');
      IdText.ContentType := 'text/plain; charset=iso-8859-1';
  
  
      // Conexão e autenticação
      try
        IdSMTP.Connect;
        IdSMTP.Authenticate;
      except
        on E:Exception do
        begin
          MessageDlg('Cannot authenticate: ' +
            E.Message, mtWarning, [mbOK], 0);
          Exit;
        end;
      end;
  
      // Envio da mensagem
      try
        IdSMTP.Send(IdMessage);
        MessageDlg('Message sent successfully!', mtInformation, [mbOK], 0);
      except
        On E:Exception do
        begin
          MessageDlg('Error while sending a message: ' +
            E.Message, mtWarning, [mbOK], 0);
        end;
      end;
    finally
      // liberação dos objetos da memória
      FreeAndNil(IdMessage);
      FreeAndNil(IdSSLIOHandlerSocket);
      FreeAndNil(IdSMTP);
    end;
  end;
  </code></pre>
  
  <p>But I only get this error from Gmail:</p>
  
  <p><a href="https://accounts.google.com/ContinueSignIn?sarp=1&amp;scc=1sdf[...]" rel="noreferrer">https://accounts.google.com/ContinueSignIn?sarp=1&amp;scc=1sdf[...]</a> Please log in via your web browser and
  then try again.
   Learn more at
   <a href="https://support.google.com/mail/answer/78754" rel="noreferrer">https://support.google.com/mail/answer/78754</a> t1sm2526415lcc.25 - gsmtp</p>
  
  <p>I did log on <a href="https://accounts.google.com/ContinueSignIn?sarp=1&amp;scc=1sdf[...]" rel="noreferrer">https://accounts.google.com/ContinueSignIn?sarp=1&amp;scc=1sdf[...]</a> but I didn't tell me anything really. </p>