Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Problema con librerias SSL al enviar email (https://www.clubdelphi.com/foros/showthread.php?t=82499)

yn4v4s 12-03-2013 23:53:26

Problema con librerias SSL al enviar email
 
Hola a todos, estoy desarrollando una App que envia un email a mi cuenta de correo (GMail), y utilize el siguiente codigo:


procedure TForm1.btnConnectClick(Sender: TObject);
var

SMTP: TIdSMTP;
Mail: TIdMessage;


begin

IdSMTP_SendMail := TIdSMTP.Create(Self);

with IdSMTP_SendMail do begin
IoHandler:=SSLIOHandler;
AuthType := satDefault;
Host := 'smtp.gmail.com';
port := 465 ;
useTLS:=utUseExplicitTLS;
Username := mi_cuenta;
Password := mi_password;
end;

mail := TIdMessage.Create(Self);
with mail do begin
From.Address := mi_cuenta;
Recipients.EMailAddresses := cuenta_del_destinatario;
Subject := 'Hola';
body.Text := 'Esto es una prueba';
end;


IdSMTP_SendMail.Connect;


IdSMTP_SendMail.Send(mail);

end;

//---------------------------------------------

La App me da la siguiente excepcion:

First chance exception at $75244B32. Exception class EIdOSSLCouldNotLoadSSLLibrary with message 'Could not load SSL library.'. Process Project1.exe (3360)

He descargado e instalado las siguientes librerias:

"libeay32.dll", "libSSL32.dll" y "ssleay32.dll", "MSVCR100.dll" y "VSINIT.dll"

Las copie en C:\Windows\SysWOW64 ya que tengo Win8 x64.

Uso el Embarcadero RAD Studio 2010 y Indy v10.5.5

Agradeceria mucho su ayuda... 1000 Gracias

Casimiro Notevi 13-03-2013 01:21:05

Recuerda poner los tags al código fuente, ejemplo:



Gracias :)

yn4v4s 13-03-2013 02:38:54

con tap
 
Código Delphi [-]
procedure TForm1.btnConnectClick(Sender: TObject);
var

  SMTP: TIdSMTP;
  Mail: TIdMessage;


begin

IdSMTP_SendMail := TIdSMTP.Create(Self);

with IdSMTP_SendMail do begin
IoHandler:=SSLIOHandler;
AuthType := satDefault;
Host := 'smtp.gmail.com';
port := 465 ;
useTLS:=utUseExplicitTLS;
Username := mi_cuenta;
Password := mi_password;
end;

mail := TIdMessage.Create(Self);
with mail do begin
From.Address := mi_cuenta;
Recipients.EMailAddresses := cuenta_del_destinatario;
Subject := 'Hola';
body.Text := 'Esto es una prueba';
end;


IdSMTP_SendMail.Connect;


IdSMTP_SendMail.Send(mail);

end;

nlsgarcia 13-03-2013 05:34:40

yn4v4s,

Cita:

...estoy desarrollando una App que envia un email a mi cuenta de correo (GMail)...
Revisa este código:
Código Delphi [-]
procedure TfrmPrincipal.btnEnviarEmailClick(Sender: TObject);
begin
  with IdMessage do
  begin
    Body.Clear();
    Recipients.Clear();
    Sender.Address := edEmailRemitente.Text;
    Recipients.EMailAddresses := edEmailDestinatario.Text;
    Subject := edAsuntoEmail.Text;
    Body.AddStrings(mCuerpoEmail.Lines);
  end;

  with IdSMTP do
  begin
    IOHandler := IdSSLIOHandlerSocket;
    IdSSLIOHandlerSocket.SSLOptions.Method := sslvSSLv23; // sslv : SSLv2, SSLv3, TLSv1, SSLv23.
    IdSSLIOHandlerSocket.SSLOptions.Mode := sslmUnassigned;
    IdSSLIOHandlerSocket.SSLOptions.VerifyMode := [];
    IdSSLIOHandlerSocket.SSLOptions.VerifyDepth := 0;
    Port := 465;
    Host := edServidorSmtp.Text;
    AuthenticationType := atLogin;
    Username := edNombreUsuario.Text;
    Password := edContrasenaUsuario.Text;
    try
       Connect(5000);
    except
       ShowMessage('Error de conexión');
    end;

    btnEnviarEmail.Enabled := false;
    try
      Send(IdMessage);
      ShowMessage('Correo enviado con éxito');
    finally
      btnEnviarEmail.Enabled := true;
    end;

    if Connected then
      Disconnect();
  end;
end;
El código anterior permite enviar emails usando Gmail como Mail Server por medio de Delphi 7, Indy 9 y openssl096. Quizás funcione correctamente en Delphi 2010 y Indy v10.5.5

Las Dlls Indy openssl096 están disponibles en el link : http://indy.fulgan.com/SSL/Archive/

El código anterior y sus Dlls esta disponible en el link: http://terawiki.clubdelphi.com/Delph...Mail+Gmail.rar

Espero sea útil :)

Nelson.

yn4v4s 13-03-2013 05:55:45

gracias hermano voy a probar

yn4v4s 13-03-2013 06:22:31

funciono perfecto, gracias hermano.

yn4v4s 13-03-2013 17:45:03

No funciona con Indy 10.5.5
 
Hola, el problema es el siguiente:

El componente IdSSLIOHandlerSocket no existe en Delphi 2010 (Indy 10.5.5) en cambio tube que sustituirlo por un IdSSLIOHandlerSocketOpenSSL en el cual la propiedad AuthenticationType ha cambiado a AuthType y atLogin no se ve por ninguna parte, ahora quedaria de la siguiente manera:

Código Delphi [-]
AuthType := satSASL;

1ero: Al enviar recibo la misma excepcion "Could not load SSL Library", luego de esto me he descargado el archivo openssl-1.0.1e-i386-win32.zip desde http://indy.fulgan.com/SSL/ con lo que ya no me pide dicha libreria, pero ahora el programa se cuelga al enviar.

Agradeceria que me ayudaran...

nlsgarcia 14-03-2013 14:55:48

yn4v4s,

Cita:

Empezado por yn4v4s
...No funciona con Indy 10.5.5...

Revisa el Msg #24 de este link:
Espero sea útil :)

Nelson.


La franja horaria es GMT +2. Ahora son las 08:17:53.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi