Buenos dias.
Os cuento que estoy intentando mandar un mail desde una aplicacion Delphi,
encontre en el blog de delphi al limite un procedimiento.
Código Delphi
[-]
procedure EnviarMensaje( sUsuario, sClave, sHost, sAdjunto, sAsunto, sDestino, sMensaje: String );
var SMTP: TIdSMTP;
Mensaje: TIdMessage;
Adjunto: TIdAttachment;
begin
SMTP := TIdSMTP.Create( nil );
SMTP.Username := sUsuario;
SMTP.Password := sClave;
SMTP.Host := sHost;
SMTP.Port := 25;
SMTP.AuthenticationType := atLogin;
Mensaje := TIdMessage.Create( nil );
Mensaje.Clear;
Mensaje.From.Name := sDestino;
Mensaje.From.Address := sDestino;
Mensaje.Subject := sAsunto;
Mensaje.Body.Text := sMensaje;
Mensaje.Recipients.Add;
Mensaje.Recipients.Items[0].Address := sDestino;
if sAdjunto <> '' then
begin
if FileExists( sAdjunto ) then
Adjunto := TIdAttachment.Create( Mensaje.MessageParts, sAdjunto );
end
else
Adjunto := nil;
try
SMTP.Connect;
except
raise Exception.Create( 'Error al conectar con el servidor.' );
end;
if SMTP.Connected then
begin
try
SMTP.Send( Mensaje );
except
raise Exception.Create( 'Error al enviar el mensaje.' );
end;
try
SMTP.Disconnect;
except
raise Exception.Create( 'Error al desconectar del servidor.' );
end;
end;
if Adjunto <> nil then
FreeAndNil( Adjunto );
FreeAndNil( Mensaje );
FreeAndNil( SMTP );
Application.MessageBox( 'Mensaje enviado correctamente.',
'Fin de proceso',MB_ICONINFORMATION );
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnviarMensaje( 'Avisos@empresa.e.telefonica.net',
'gestion',
'smtp.telefonica.net',
'C:\Documento.txt',
'Te envio mi documento',
'correo_receptor@gmail.com',
'Adjunto archivo: documento.zip' );
end;
Como veis las cuentas de emision es una de empresas de telefonica
y la de recepcion es una de Gmail.
si lo compilo en estas condiciones al pulsar el boton me da el siguiente error.
"EIdProtocolReplyError...... 5.7.0... Authentication Rejected"
Se que el servidor de telefonica requiere autentificacion pero para probar elimine la linea
Código Delphi
[-]SMTP.AuthenticationType := atLogin;
y el error a pasado a ser....
"EIdProtocolReplyError...... 5.1.0..... <correo_receptor@gmail.com> Sender rejected".
Alguna pista??????????