Fórum erro no envio de email com ssl #458397
14/10/2013
0
Estou precisando fazer envio de e-mail diretamente do meu sistema e estou encontrando algumas dificuldades e preciso que alguém me ajude por favor...
buscando ajuda no fórum, encontrei uma rotina de teste de conexão com o servidor smtp que implementei no meu sistema e funciona corretamente, segue abaixo :
Try
Screen.Cursor := crHourGlass;
IdSMTP1.Host := Trim(DBEdit2.Text);
IdSMTP1.Username := Trim(DBEdit3.Text);
IdSMTP1.Password := Trim(DBEdit4.Text);
IdSMTP1.Port := StrToInt(Trim(DBEdit5.Text));
//-- requer autenticacao
if DBCheckBox6.Checked then
IdSMTP1.AuthenticationType:= atLogin
else
IdSMTP1.AuthenticationType:= atNone;
//-- conexao segura SSL
if DBCheckBox5.Checked then
IdSMTP1.IOHandler := IdSSLIOHandlerSocket1
else
IdSMTP1.IOHandler := nil;
if NOT IdSMTP1.Connected then
IdSMTP1.Connect(2000);
if IdSMTP1.Connected then
ShowMessage(''''CONECTADO> Teste de conexão realizado com sucesso!'''')
else
ShowMessage(''''DESCONECTADO> Tesde de conexão FALHOU!'''');
Except
on E:Exception do
ShowMessage(e.Message);
end;
IdSMTP1.Disconnect;
Screen.Cursor:= crDefault;
muito bem, agora segue a rotina que fiz para enviar o e-mail :
try
Screen.Cursor := crHourGlass;
vDoctor := DMGeral.GetDoctor(varUsuario,''''Null'''');
with DMGeral.QGeral do begin
Close;
SQL.Text := ''''Select E03_SMTP, E03_EMAIL, E03_USER_SMTP, E03_PASS_SMTP, E03_PORT_SMTP, E03_NOME_SMTP, E03_AUTENTICA_SMTP, E03_SSL from GE003 Where E03_CodMed = :Medico'''';
Parameters[0].Value := vDoctor;
Open;
if Eof then begin
MessageDlg(''''Este Médico não possui e-mail cadastrado no sistema!'''',mtInformation,[mbOK],0);
FEMail.Close;
end;
end;
StatusBar1.Panels[0].Text := ''''Conectando ao Servido SMTP: ''''+DMGeral.QGeral.Fields[0].AsString;
with IdMsgSend do
begin
if sendAction = acUpdate then
lbDocumento.Caption := FMailBox.SaveDBAttach(''''SAVE'''');
TIdAttachment.Create(MessageParts, lbDocumento.Caption);
Body.Assign(memMessage.Lines);
From.Name := DMGeral.QGeral.Fields[5].Value;
From.Address := DMGeral.QGeral.Fields[1].Value;
ReplyTo.EMailAddresses := DMGeral.QGeral.Fields[1].Value;
Recipients.EMailAddresses := edPara.Text;
Subject := edAssunto.Text;
Priority := TIdMessagePriority(1);
end;
showmessage(DMGeral.QGeral.Fields[7].AsString);
if DMGeral.QGeral.Fields[7].AsString = ''''TRUE'''' then
SMTP.IOHandler := IdSSLIOHandlerSocket1
else
SMTP.IOHandler := nil;
if DMGeral.QGeral.Fields[6].Value = ''''TRUE'''' then
SMTP.AuthenticationType := atLogin
else
SMTP.AuthenticationType := atNone;
SMTP.Host := Trim(DMGeral.QGeral.Fields[0].Value);
SMTP.Username := Trim(DMGeral.QGeral.Fields[2].Value);
SMTP.Password := Trim(DMGeral.Decrypt(DMGeral.QGeral.Fields[3].Value,1298,5786,8956));
SMTP.Port := StrToInt(Trim(DMGeral.QGeral.Fields[4].Value));
try
ProgressBar1.Max := SMTP.ReadTimeout div 20;
Timer1.Enabled := true;
if NOT SMTP.Connected then
SMTP.Connect(2000);
except
Timer1.Enabled:=false;
ProgressBar1.Position:=0;
MessageDlg(''''Não foi possível conectar ao servidor SMTP: ''''+SMTP.Host,mtInformation,[mbOK],0);
StatusBar1.Panels[0].Text := ''''Desconectado'''';
Close;
end;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;;
for I:=0 to IdMsgSend.MessageParts.Count-1 do
if IdMsgSend.MessageParts[I] is TIdAttachment then
DeleteFile(TIdAttachment(IdMsgSend.MessageParts[I]).StoredPathName);
end;
finally
Screen.Cursor := crDefault;
end;
só que o sistema fica pensando + de 30min e depois da o seguinte erro:
EidOSSL ConnectError with message ''''Error connecting with SSL''''
Desde já. agradeço a ajuda....
Lindolfo Junior
Curtir tópico
+ 0Posts
14/10/2013
Nícolas Braz
Gostei + 0
14/10/2013
Lindolfo Junior
JR
Gostei + 0
14/10/2013
Nícolas Braz
JR
Eu tive esse mesmo problema que você está tendo eu resolvi ele da seguinte maneira pegando essas dlls.
http://www.4shared.com/zip/E6Pp8qRt/dlls.html
Gostei + 0
14/10/2013
Nícolas Braz
Gostei + 0
14/10/2013
Lindolfo Junior
JR
Gostei + 0
14/10/2013
Nícolas Braz
Aqui é Delphi XE com indy 10.5.7
Eu não tenho certeza mas procura no google se precisa colocar as dlls na pasta do windows.
Estou indo dormir amanhã conversamos mais.
Gostei + 0
14/10/2013
Lindolfo Junior
boa noite!!
JR
Gostei + 0
15/10/2013
Marlon Nardi
var
idSSLv : TIdSSLIOHandlerSocketOpenSSL;
if idSSLv = Nil then
idSSLv := TIdSSLIOHandlerSocketOpenSSL.Create();
if SSL then
begin
idSSLv.SSLOptions.Method := sslvTLSv1;
idSSLv.SSLOptions.Mode := sslmClient;
IOHandler := idSSLv;
if TLS then
UseTLS := utUseExplicitTLS;
if Not TLS then
UseTLS := utUseImplicitTLS; //Yahoo, Hotmail, Gmail...
end
else
begin
IOHandler := nil;
UseTLS := utNoTLSSupport;
end;Gostei + 0
15/10/2013
Lindolfo Junior
eu adicionei o código mas esta dando erro no tipo da variável, precisa adicionar alguma coisa no uses??
vlw
Gostei + 0
15/10/2013
Lindolfo Junior
VLW
Gostei + 0
15/10/2013
Nícolas Braz
https://www.devmedia.com.br/envio-de-e-mails-com-boas-praticas/28693
Gostei + 0
15/10/2013
Lindolfo Junior
Gostei + 0
15/10/2013
José
Amigo mas você pode conseguir o artigo individualmente, não precisa exatamente ser assinante, basta você adquirir créditos e poderá
comprar artigos e vídeos aulas individuais.
Gostei + 0
16/10/2013
Lindolfo Junior
Gostei + 0
18/10/2013
Lindolfo Junior
5.7.0 Must issue a STARTTLS command first. i4sm6009962qan.0 - gsmtp
se alguém tiver alguma idéia desse problema eu agradeço desde já o apoio
VLW
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)