delphi connection closed gracefully

Using D7 + Indy 10 latest build.

My code is using TIdSMTP to send email. I keep getting «Connection closed gracefully» at some end-users, and the email is never sent.

The code is like:

3 Answers 3

EIdConnClosedGracefully is an exception signaling that the connection has been closed by the other side intentionally. This is not the same as a broken connection which would cause a connection reset error. If the other side has closed the connection and the socket is read or written to, EIdConnClosedGracefully will be raised by Indy. This is similar to attempting to read or write to a file that has been closed without your knowledge.

In some cases this is a true exception and your code needs to handle it. In other cases (typically servers) this is a normal part of the functioning of the protocol and Indy handles this exception for you. Even though Indy catches it, when running in the IDE the debugger will be triggered first. You can simply press F9 to continue and Indy will handle the exception, but the constant stopping during debugging can be quite annoying. In the cases where Indy catches the exception, your users will never see an exception in your program unless it is run from the IDE.

In my case the error was caused because I used a sender email address from a different domain than the one hosted by the smtp server, that’s why the smtp server rejected the connection.

In my experience, in case of AT&T server, it rejects an email address which is not @att.net address in the MAIL FROM . More info can be determined by logging the error using TIdLogEvent for these users that receive it, otherwise the error report is rather vague — if the disconnect (Connection closed gracefully) occurs right after the MAIL FROM then it might indicate a server policy rejecting an email with the domain which it doesn’t host as explained by Toni as well.

Otherwise the «Connection closed gracefully» error means that an attempt is being made to read/write to socket that has been closed by the peer intentionally — in your case, peer is the SMTP server you connect to. It is different than the «Connection reset» error which indicates a broken connection. In both cases, the connection is no longer present and you can’t read/write anymore to it.

Not the answer you’re looking for? Browse other questions tagged delphi indy or ask your own question.

Linked

Hot Network Questions

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.15.35459

Проблемы при получении данных через IdHTTP по протоколу https.
На сайте есть много однотипных страниц с данными, которые мне нужно закачать (новости). Я сделал закачку через IdHTTP + IdSSLIOHandlerSocketOpenSSL:

> > > > >
в целом работает, но некоторые страницы (

1 из сотни) не загружаются, при

try
IdHTTP.Get(‘https://. ‘,SResponse);
IdHTTP.Disconnect;
except
on E:Exception do

вылетает исключение: Connection Closed Gracefully, хотя через браузер эти страницы открываются нормально.
Ошибка происходит в модуле IdHTTP.pas, procedure TIdCustomHTTP.DoRequest, строке

В чем может быть причина? Как её устранить? Если устранить нельзя — как ещё можно получить содержимое страницы? Через TwebBrowser при установленном IE7 всё очень грустно — кривой сертификат сайта.
(Delphi 7, Indy 10)

Delphi Error «connection closed gracefully»

Delphi Error «connection closed gracefully»

Hello, I’m trying to send an email using delphi win32
but it is giving me this error:
«connection closed gracefully»

any suggestions how to ignore this exception??

RE: Delphi Error «connection closed gracefully»

In an open world there’s no need for windows and gates
www.ubuntu.com

RE: Delphi Error «connection closed gracefully»

The error message indicates that a remote connection was closed without your request, but that it hasn’t caused any problems — ie. both clients have finished talking.

Оцените статью