Indy10, TIdSMTP, how to get protocol log?
Posted by jpluimers on 2020/12/17
Indy is great, but not well documented so: [WayBack] Indy10, TIdSMTP, how to get protocol log? I try to get log from SMTP communication, like this (copy from wiki): {code} S: 220 smtp.example.com ESMTP P… – Jacek Laskowski – Google+
Q
Indy10,
TIdSMTP
, how to get protocol log?I try to get log from SMTP communication, like this (copy from wiki):
{code}
S: 220 smtp.example.com ESMTP Postfix
C: HELO relay.example.com
S: 250 smtp.example.com, I am glad to meet you
C: MAIL FROM:<bob@example.com>
S: 250 Ok
C: RCPT TO:<alice@example.com>
S: 250 Ok
C: RCPT TO:<theboss@example.com>
S: 250 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: From: "Bob Example" <bob@example.com>
C: To: Alice Example <alice@example.com>
C: Cc: theboss@example.com
C: Date: Tue, 15 January 2008 16:02:43 -0500
C: Subject: Test message
{code}
but without success :-(
I try use many events from
TIdSMTP
, TId
LogEvent,TIdSSLIOHandlerSocketOpenSSL
but result is low level like bytes, status etc. not true SMTP log.How to do it?
A
![]()
Did you try using TIdLogFile like it is shown here? (It is the first hit in Google) For me it created readable logfiles. rajapet.com – How to log the TIDSmtp component
try
try
IdLogFile.Active := true;
fsmtp.IOHandler := TIdIOHandler.MakeDefaultIOHandler(fsmtp);
fsmtp.IOHandler.Intercept := IdLogFile;
fsmtp.IOHandler.OnStatus := fsmtp.OnStatus;
fSMTP.Connect;
fSMTP.Send(fMessage);
except
on e: exception do begin
MessageDlg(‘Error sending message: ‘ + e.Message, mtError, [mbOK], 0);
end;
end;
finally
if fSMTP.Connected then
fSMTP.Disconnect(true);
IdLogFile.Active := false;
end;
- [Archive.is] Internet Direct (Indy): TIdSMTP Class
- [Archive.is] Internet Direct (Indy): TIdLogFile Class
- [Archive.is] Internet Direct (Indy): TIdIOHandler Class
- [Archive.is] Internet Direct (Indy): TIdIOHandler.Intercept Property
- [WayBack] Ruminated Rumblings
- [WayBack] SMTP Mail and Indy (again) | Ruminated Rumblings
+Rik van Kekem Thanks! I need to setLogEvent.Active: = True
! ;-)
Sending stuff still might be tough, so you might want to consider alternatives too: [WayBack] I need to add to the REST server the ability to send emails with attachments of different types. Which library is best to use? Indy or maybe ICS? Of cou… – Jacek Laskowski – Google+
Q
I need to add to the REST server the ability to send emails with attachments of different types. Which library is best to use? Indy or maybe ICS? Of course with SSL/TLS support.
A
+Balázs Szakály, YES! Synapse. Let’s get people using it more. You can give it some criticism surely, but consider the pro’s:It is straight-forwardly-written so when you hit a wall you can read the code easily (compared to other solutions),
You can inherit, extend and extrapolate, re-use and tweak,
Very Delphi-ish (TMimeMessages = TStringList or some such, not at at devmachine atm)
Compact and free!
Quite stable too.
–jeroen
Leave a Reply