Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Problema envió correo (https://www.clubdelphi.com/foros/showthread.php?t=84682)

Taburiente 21-11-2013 20:06:45

Problema envió correo
 
Hola a todos,

A ver si me podéis echar una mano,tengo una aplicación que lo que hace entre otras cosas es enviar un fichero a una dirección de correo y que funcionaba correctamente hasta que telefónica me cambio el servido smtp y el pueto a 587 con seguridad TLS, y desde entonces obtengo erro 5.7.1, mi codigo es el siguiente

Cita:

function TfrmHistorico.EnviarAlbaran(const sFichAlbaran: string): boolean;
var
ServidorSMTP: TIdSMTP;
MailMessage: TIdMessage;
Attachment: TIdAttachment;

begin
Result := FALSE;

if FileExists(sFichAlbaran) then
begin
ServidorSmtp := TIdSMTP.Create(Self);

MailMessage := TIdMessage.Create(Self);
with MailMessage do
begin
Subject := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'ASUNTO', '');
//
Body.Clear;
Body.Add('Albarán: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE1', 'ALBARAN', ''));
Body.Add('Fecha: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE1', 'FECHA', ''));
Body.Add('Usuario: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE4', 'USR_OID', ''));
Body.Add('Nombre: '+LeeEnFicheroIni(sFichAlbaran, 'PARTE4', 'USR_NOMBRE', ''));
//
From.Address := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'REMITENTE', '');
From.Name := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SEUDONIMO', '');
//
Recipients.EMailAddresses := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'DESTINATARIO', '');
end;

Attachment := TIdAttachment.Create(MailMessage.MessageParts, sFichAlbaran);

ServidorSMTP.Host := LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_SMTP', '');
ServidorSMTP.Port := StrToIntDef(LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_PUERTO', '587'), 587);
ServidorSMTP.AuthenticationType:= atLogin;

// Datos de la cuenta de usuario
ServidorSMTP.Username:= 'albaranes@xxxx.e.telefonica.net'; // LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_USUARIO', '');

servidorSMTP.Password:= '111111'; // LeeEnFicheroIni(sFichConfig, 'EMAIL', 'SERVIDOR_CONTRASENA', '');
try
servidorSMTP.Connect(10000);

try
servidorSMTP.Send(MailMessage);

Result := TRUE;

except on E: Exception do
ShowMessage('ERROR al enviar albarán...'+#13+#13+E.Message);
end;

finally
servidorSMTP.Disconnect;
Attachment.Free;
MailMessage.Free;
servidorSMTP.Free;
end;

end
else
raise Exception.Create('ERROR no encuentro el fichero de albarán...'+sFichAlbaran);
end;
y en el fichero ini, lo siguiente

Cita:

SERVIDOR_SMTP=smtp.office365.com
SERVIDOR_PUERTO=587
SERVIDOR_USUARIO=albaranes@xxxx.e.telefonica.net
SERVIDOR_CONTRASENA=111111
El programa esta hecho con Delphi 7 y la versión de Indy es la 9

Agradecería cualquier ayuda.

Un saludo

juanelo 22-11-2013 15:55:30

Que tal Taburiente,
Tienes que usar el componente TIdIOHandlerSocket y asignarlo a la propiedad IOHandler del TIdSMTP.
Saludos.

Taburiente 23-11-2013 10:43:55

Lo probare y te diré algo,,gracias

jcosta 25-11-2013 18:25:10

A mi me pasaba lo mismo, en el hilo "Enviar un e-mail con delphi 7" he puesto cómo lo he solucionado (no me deja poner el link). Es para Indy 9 pero en C++ Builder. Espero que te sirva.

Taburiente 25-11-2013 20:02:43

Este es el hilo con la solución de
Cita:

jcosta
,,gracias a todos por vuestra ayuda...tema cerrado




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

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