Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Pametros de envio de correo inconsistentes (https://www.clubdelphi.com/foros/showthread.php?t=95063)

ArtPortEsp 10-02-2021 22:43:58

Pametros de envio de correo inconsistentes
 
1 Archivos Adjunto(s)
Buen dia;

me encuentro con un problema extraño, los parámetros que tengo para envío de correos, funcionan sin problema en la maquina de desarrollo, pero no en las maquinas de usuarios (he probado con 2 maquinas diferentes en la misma conexión de internet).

** adjunto imagen de los parametros *

ArtPortEsp 10-02-2021 23:10:59

agregado:

Esos parámetros SOLO funcionan desde el IDE (delphi 7) pero si ejecuto la aplicación fuera del IDE no funcionan.

El error es : Connection closed gracefully

Casimiro Notevi 10-02-2021 23:11:25

Si no dices al menos el error que muestra.

ArtPortEsp 11-02-2021 02:59:36

Cita:

Empezado por Casimiro Notevi (Mensaje 539994)
Si no dices al menos el error que muestra.

SMTP: connection closed gracefully

Casimiro Notevi 11-02-2021 10:11:29

Sí, pero cuándo, en qué línea, pon el código para que veamos algo.

ArtPortEsp 11-02-2021 16:28:32

Cita:

Empezado por Casimiro Notevi (Mensaje 539997)
Sí, pero cuándo, en qué línea, pon el código para que veamos algo.

ah ok, tratare de ser mas especifico.... estoy usando el código que encontré en:

https://proyectoa.com/como-enviar-co...i-6-e-indy-10/

el cual es:

Código Delphi [-]
var
  mail : TIdMessage;
  adjuntos : TStrings;
  i,x : integer;
begin
     if txtServidorSMTP.Text = '' then
     begin
          MessageDlg ('Debe indicar el la dirección del servidor de SMTP.', mtWarning, [mbok], 0);
          tabDatos.Show;
          exit;
     end;

     if (lsAutenticacion.Text <> 'Ninguna') and ((txtUsuario.Text = '') or (txtContrasena.Text = '')) then
     begin
          MessageDlg ('Debe indicar el usuario y contraseña de autenticación del servidor SMTP.', mtWarning, [mbok], 0);
          tabDatos.Show;
          exit;
     end;

     if lsTLS.Text = '' then
     begin
          MessageDlg ('Debe indicar si requiere TLS / SSL.', mtWarning, [mbok], 0);
          tabDatos.Show;
          exit;
     end;

     if txtPuerto.Text = '' then
     begin
          MessageDlg ('Debe indicar el puerto de envío de mail (por defecto para TLS ' + 'es 587 y sin TLS es 25).', mtWarning, [mbok], 0);
          tabDatos.Show;
          exit;
     end;

     if txtRemitenteNombre.Text = '' then
     begin
          MessageDlg ('Debe indicar el nombre del remitente.', mtWarning, [mbok], 0);
          tabDatos.Show;
          exit;
     end;

     if txtRemitenteMail.Text = '' then
     begin
          MessageDlg ('Debe indicar el e-mail del remitente.', mtWarning, [mbok], 0);
          tabDatos.Show;
          exit;
     end;
     if txtDestinatario.Text = '' then
     begin
          MessageDlg ('Debe indicar el e-mail del destinatario (para varios mails separar con comas).',
           mtWarning, [mbok], 0);
          tabEnviarMail.Show;
          exit;
     end;
     if txtAsunto.Text = '' then
     begin
          MessageDlg ('Debe indicar el asunto del correo electrónico.', mtWarning, [mbok], 0);
          tabEnviarMail.Show;
          exit;
     end;
     if txtMensaje.Text = '' then
     begin
          MessageDlg ('Debe indicar el cuerpo del correo electrónico.', mtWarning, [mbok], 0);
          tabEnviarMail.Show;
          exit;
     end;
     if (pos('adjunto', AnsiLowerCase(txtMensaje.Text)) > 0) and (lFicherosAdjuntos.Count = 0) then
     begin
          if MessageDlg ('Ha introducido la palabra "adjunto" en el cuerpo pero no ha adjuntado documentos ' +
               'al correo electrónico ¿Desea continuar con el envío sin adjuntos?',
               mtConfirmation, [mbYes, mbNo], 0) = mrno then
          begin
               tabEnviarMail.Show;
               exit;
          end;
     end;


     //Si no está conectado al servidor SMTP conectar
     with idSMTP do
     begin
          if lsMetdoSSL.Text = 'sslvTLSv1' then
               IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvTLSv1;
          if lsMetdoSSL.Text = 'sslvTLSv2' then
               IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvSSLv2;
          if lsMetdoSSL.Text = 'sslvTLSv23' then
               IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvSSLv23;
          if lsMetdoSSL.Text = 'sslvTLSv3' then
               IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvSSLv3;

          IoHandler := IdSSLIOHandlerSocketOpenSSL1;

          //Tipo de autenticación
          if lsAutenticacion.Text = 'Defecto' then
               AuthType := atDefault;
          if lsAutenticacion.Text = 'Ninguna' then
               AuthType := atNone;
          if lsAutenticacion.Text = 'SASL' then
               AuthType := atSASL;

          //Si se requiere autenticación para el envío indicar usuario y contraseña
          Username := txtUsuario.Text;
          Password := txtContrasena.Text;
          Host := txtServidorSMTP.Text;

          //Usar TLS SLL para el envío
          if lsTLS.Text = 'TLS explícito' then
            useTLS := utUseExplicitTLS;
          if lsTLS.Text = 'Sin soporte TLS' then
            useTLS := utNoTLSSupport;
          if lsTLS.Text = 'TLS implícito' then
            useTLS := utUseExplicitTLS;
          if lsTLS.Text = 'TLS requerido' then
            useTLS := utUseExplicitTLS;

          //Puerto que se usará para la conexión con el servidor SMTP, en el caso de TLS el de defecto es 587
          port := strtoint(txtPuerto.Text);
     end;

     try
          txtResultado.Lines.add(DateTimeToStr(now) + ' Conectando con el servidor ' + txtServidorSMTP.Text);
          idSMTP.Connect;
          txtResultado.Lines.add(DateTimeToStr(now) + ' Conectado a ' + txtServidorSMTP.Text);
     except
          on e : exception do
          begin
               txtResultado.Lines.add(DateTimeToStr(now) + ' Error al conectar al servidor SMTP. ' + e.ClassName + ' ' + e.Message);
               MessageDlg('Error al conectar con servidor SMTP: ' + e.Message, mtError, [mbok], 0);
          end;
     end;

     mail := TIdMessage.Create(Self);
     with mail do
     begin
          From.Name                 := txtRemitenteNombre.Text;
          From.Address              := txtRemitenteMail.Text;
          Recipients.EMailAddresses := txtDestinatario.Text;
          CCList.EMailAddresses     := txtCC.Text;
          BccList.EMailAddresses    := txtCCO.Text;
          Subject                   := txtAsunto.Text;

          body.Text := txtMensaje.Text;

          //Cargar ficheros adjuntos seleccionados
          adjuntos := lFicherosAdjuntos.Items;
          for i := 0 to adjuntos.Count - 1 do
          begin
               if FileExists(adjuntos.Strings[i]) then
               begin
                    TIdAttachmentFile.Create(MessageParts, adjuntos.Strings[i])
               end;
          end;
     end;

     try
          idSMTP.Send(mail);
          txtResultado.Lines.add(DateTimeToStr(now) + ' Mensaje enviado correctamente ('+inttostr(x)+')');
          MessageDlg('Mensaje enviado correctamente.', mtInformation, [mbok], 0);
          if idSMTP.Connected then idSMTP.Disconnect;
     except
          on e : exception do
          begin
               txtResultado.Lines.add(DateTimeToStr(now) + ' Error al enviar mensaje. ' + e.ClassName + ' ' + e.Message);
               MessageDlg('Error al enviar e-mail: ' + e.Message, mtError, [mbok], 0);
               if idSMTP.Connected then
                    idSMTP.Disconnect;
          end;
     end;

y el mismo funciona perfectamente en mi maquina, pero no así en las maquinas de los usuarios, le puse unos mensajes (que no inclui en el codigo) para tratar de seguir lo que hacia el programa en una de las maquinas y en la linea :

Código:

idSMTP.Connect;
es donde se interrumpe el proceso y envía el error que menciono...

tengo la sospecha que las maquinas de usuarios por "alguna extraña razón" no tienen acceso a las librerías : ssleay32.dll y libeay32.dll ; a pesar que están en la misma carpeta que el ejecutable (en mi maquina las librerías están también en Windows/System32) y en las carpetas de otras aplicaciones (aunque al parecer con versiones diferentes (por la fecha y tamaño de los archivos)

lo que pienso probar el dia de hoy es poner las librerías en Windows/System32 y tal vez usar alguna otra versión de las mismas.

egostar 11-02-2021 20:33:24

Cita:

Empezado por ArtPortEsp (Mensaje 540003)
......tal vez usar alguna otra versión de las mismas.

Comienza utilizando la misma versión que tienes en tu maquina de desarrollo.

Saludos


La franja horaria es GMT +2. Ahora son las 05:06:11.

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