Added logging for SMTP communication

SVN revision: 653
This commit is contained in:
Stefan Ritt 2004-01-07 14:28:58 +00:00
parent dd1f467714
commit 0a8f862801
2 changed files with 56 additions and 16 deletions

View File

@ -131,8 +131,7 @@ New message cannot be written to directory "%s" = Neuer Eintrag kann nicht ins V
Only user <i>%s</i> can edit this entry = Nur Benutzer <i>%s</i> kann diesen Eintrag ändern Only user <i>%s</i> can edit this entry = Nur Benutzer <i>%s</i> kann diesen Eintrag ändern
# #
# New strings for V2.0 # V2.0
#
Display full message = Ganzer Eintrag darstellen Display full message = Ganzer Eintrag darstellen
Display threads = Antwortkette darstellen Display threads = Antwortkette darstellen
Logbook is empty = Logbuch ist leer Logbook is empty = Logbuch ist leer
@ -142,7 +141,7 @@ and all its replies = und alle Antworten
Message ID = Eintrag-ID Message ID = Eintrag-ID
# #
# New strings for V2.1.0 # V2.1.0
Not logged in = Nicht eingeloggt Not logged in = Nicht eingeloggt
Login = Anmelden Login = Anmelden
Page %d of %d = Seite %d von %d Page %d of %d = Seite %d von %d
@ -165,7 +164,7 @@ Register as new user = Als neuer Benutzer anmelden
name may not contain blanks = Name darf keine Leerzeichen enthalten name may not contain blanks = Name darf keine Leerzeichen enthalten
# #
# New strings for V2.1.1 # V2.1.1
A new ELOG user has been registered on %s = Ein neuer Benutzer hat sich auf %s angemeldet A new ELOG user has been registered on %s = Ein neuer Benutzer hat sich auf %s angemeldet
Email = Email Email = Email
User "%s" registered on logbook "%s" = Benutzer "%s" im Logbuch "%s" registriert User "%s" registered on logbook "%s" = Benutzer "%s" im Logbuch "%s" registriert
@ -178,7 +177,7 @@ Are you sure to delete these messages? = Diese Eintr
Select = Auswählen Select = Auswählen
# #
# New strings for V2.2.0 # V2.2.0
No message selected for deletion = Kein Eintrag zum löschen ausgewählt No message selected for deletion = Kein Eintrag zum löschen ausgewählt
No message selected = Kein Eintrag ausgewählt No message selected = Kein Eintrag ausgewählt
All entries = Alle Einträge All entries = Alle Einträge
@ -196,11 +195,11 @@ Selected entries = Ausgew
Enable email notifications = Email-Benachrichtigung ermöglichen Enable email notifications = Email-Benachrichtigung ermöglichen
# #
# New strings for V2.2.2 # V2.2.2
A old entry has been updated on %s = Ein alter Eintrag wurde von %s geändert A old entry has been updated on %s = Ein alter Eintrag wurde von %s geändert
# #
# New strings for V2.2.4 # V2.2.4
Collapse = eingeklappt Collapse = eingeklappt
Expand = erweitert Expand = erweitert
Full = ausführlich Full = ausführlich
@ -208,7 +207,7 @@ Summary = zusammengefasst
Threaded = mit&nbsp;Antwortketten Threaded = mit&nbsp;Antwortketten
# #
# New strings for V2.2.6 # V2.2.6
ELOG Entries = ELOG Einträge ELOG Entries = ELOG Einträge
Filters = Filter Filters = Filter
Mode = Modus Mode = Modus
@ -218,14 +217,14 @@ and all their replies = und alle Antworten
Your request has been forwarded to the administrator. You will be notified by email upon activation of your new account. = Ihr Gesuch wurde an den Administrator weitergeleitet. Sie werden per Email benachrichtigt, wenn Ihr Zugang aktiviert wurde. Your request has been forwarded to the administrator. You will be notified by email upon activation of your new account. = Ihr Gesuch wurde an den Administrator weitergeleitet. Sie werden per Email benachrichtigt, wenn Ihr Zugang aktiviert wurde.
# #
# New strings for V2.3.1 # V2.3.1
Upload = Hochladen Upload = Hochladen
Requested = Erfordert Requested = Erfordert
Registration request on logbook "%s" = Registrierungsanforderung für Logbuch "%s" Registration request on logbook "%s" = Registrierungsanforderung für Logbuch "%s"
A new ELOG user wants to register on "%s" = Ein neuer Benutzer möchte sich auf "%s" registrieren A new ELOG user wants to register on "%s" = Ein neuer Benutzer möchte sich auf "%s" registrieren
# #
# New strings for V2.3.2 # V2.3.2
One message = Ein Eintrag One message = Ein Eintrag
%d messages = %d Einträge %d messages = %d Einträge
and its replies = mit Antworten and its replies = mit Antworten
@ -234,7 +233,7 @@ moved successfully from "%s" to "%s" = erfolgreich von "%s" nach "%s" verschoben
copied successfully from "%s" to "%s" = erfolgreich von "%s" nach "%s" kopiert copied successfully from "%s" to "%s" = erfolgreich von "%s" nach "%s" kopiert
# #
# New strings for V2.3.4 # V2.3.4
Last x = Letzte x Last x = Letzte x
Only user <i>%s</i> can delete this entry = Dieser Eintrag kann nur von <i>%s</i> gelöscht werden Only user <i>%s</i> can delete this entry = Dieser Eintrag kann nur von <i>%s</i> gelöscht werden
Search text also in attributes = Text auch in Attributen suchen Search text also in attributes = Text auch in Attributen suchen
@ -243,7 +242,7 @@ Login as different user = Als anderer Benutzer anmelden
User <i>"%s"</i> has no access to logbook <i>"%s"</i> = Benutzer <i>"%s"</i> hat keinen Zugriff auf Logbuch <i>"%s"</i> User <i>"%s"</i> has no access to logbook <i>"%s"</i> = Benutzer <i>"%s"</i> hat keinen Zugriff auf Logbuch <i>"%s"</i>
# #
# New strings for V2.3.5 # V2.3.5
Date = Datum Date = Datum
ID = ID ID = ID
Change elogd.cfg = elogd.cfg ändern Change elogd.cfg = elogd.cfg ändern
@ -264,7 +263,7 @@ Enter your user name or email address = Bitte Benutzernamen oder Email-Adresse e
Password recovery for ELOG %s = Kennwort-Wiederherstellung für ELOG %s Password recovery for ELOG %s = Kennwort-Wiederherstellung für ELOG %s
# #
# New string for V2.3.6 # V2.3.6
Host = Computer Host = Computer
Your ELOG account has been activated = Ihr ELOG Konto wurde aktiviert Your ELOG account has been activated = Ihr ELOG Konto wurde aktiviert
Activate = Aktivieren Activate = Aktivieren
@ -272,17 +271,23 @@ Maximum number of attachments reached = Maximale Anzahl von Anh
Invalid user name <i>"%s"</i> = Falscher Benutzer-Name <i>"%s"</i> Invalid user name <i>"%s"</i> = Falscher Benutzer-Name <i>"%s"</i>
# #
# New string for V2.3.7 # V2.3.7
User = Benutzer User = Benutzer
on = auf on = auf
computer = Computer computer = Computer
Entry is currently edited by = Eintrag wird momentan bearbeitet von Entry is currently edited by = Eintrag wird momentan bearbeitet von
# #
# New string for V2.3.9 # V2.3.9
recipients = Empfänger recipients = Empfänger
Suppress shell execution = Kommando-Ausführung unterdrücken Suppress shell execution = Kommando-Ausführung unterdrücken
# #
# New string for V2.4.0 # V2.4.0
Maximum number of replies (%d) exceeded Maximum number of replies (%d) exceeded
# V2.4.1
by = von
Change [global] = [global] ändern

View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 1.174 2004/01/07 14:28:58 midas
Added logging for SMTP communication
Revision 1.173 2004/01/07 14:05:14 midas Revision 1.173 2004/01/07 14:05:14 midas
Fixed bug with permissions Fixed bug with permissions
@ -1055,6 +1058,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
if (verbose) if (verbose)
printf("\n\nEmail from %s to %s, SMTP host %s:\n", from, to, smtp_host); printf("\n\nEmail from %s to %s, SMTP host %s:\n", from, to, smtp_host);
logf(lbs, "Email from %s to %s, SMTP host %s:\n", from, to, smtp_host);
/* count attachments */ /* count attachments */
n_att = 0; n_att = 0;
@ -1087,6 +1091,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
recv_string(s, str, strsize, 10000); recv_string(s, str, strsize, 10000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
/* drain server messages */ /* drain server messages */
do { do {
@ -1094,23 +1099,28 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
recv_string(s, str, strsize, 300); recv_string(s, str, strsize, 300);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
} while (str[0]); } while (str[0]);
snprintf(str, strsize - 1, "HELO %s\r\n", host_name); snprintf(str, strsize - 1, "HELO %s\r\n", host_name);
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, "MAIL FROM: <%s>\r\n", from); snprintf(str, strsize - 1, "MAIL FROM: <%s>\r\n", from);
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
/* break recipients into list */ /* break recipients into list */
n = strbreak(to, list, 1024); n = strbreak(to, list, 1024);
@ -1120,20 +1130,24 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
/* increased timeout for SMTP servers with long alias lists */ /* increased timeout for SMTP servers with long alias lists */
recv_string(s, str, strsize, 30000); recv_string(s, str, strsize, 30000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
} }
snprintf(str, strsize - 1, "DATA\r\n"); snprintf(str, strsize - 1, "DATA\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
if (email_to) if (email_to)
snprintf(str, strsize - 1, "To: %s\r\n", to); snprintf(str, strsize - 1, "To: %s\r\n", to);
@ -1143,28 +1157,33 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, "From: %s\r\nSubject: %s\r\n", from, subject); snprintf(str, strsize - 1, "From: %s\r\nSubject: %s\r\n", from, subject);
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, "X-Mailer: Elog, Version %s\r\n", VERSION); snprintf(str, strsize - 1, "X-Mailer: Elog, Version %s\r\n", VERSION);
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
if (url) { if (url) {
snprintf(str, strsize - 1, "X-Elog-URL: %s\r\n", url); snprintf(str, strsize - 1, "X-Elog-URL: %s\r\n", url);
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
} }
snprintf(str, strsize - 1, "X-Elog-submit-type: web|elog\r\n"); snprintf(str, strsize - 1, "X-Elog-submit-type: web|elog\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
time(&now); time(&now);
ts = localtime(&now); ts = localtime(&now);
@ -1177,12 +1196,14 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
if (n_att > 0) { if (n_att > 0) {
snprintf(str, strsize - 1, "MIME-Version: 1.0\r\n"); snprintf(str, strsize - 1, "MIME-Version: 1.0\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
sprintf(boundary, "%04X-%04X=:%04X", rand(), rand(), rand()); sprintf(boundary, "%04X-%04X=:%04X", rand(), rand(), rand());
snprintf(str, strsize - 1, "Content-Type: MULTIPART/MIXED; BOUNDARY=\"%s\"\r\n\r\n", snprintf(str, strsize - 1, "Content-Type: MULTIPART/MIXED; BOUNDARY=\"%s\"\r\n\r\n",
@ -1190,29 +1211,34 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, snprintf(str, strsize - 1,
" This message is in MIME format. The first part should be readable text,\r\n"); " This message is in MIME format. The first part should be readable text,\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, snprintf(str, strsize - 1,
" while the remaining parts are likely unreadable without MIME-aware tools.\r\n\r\n"); " while the remaining parts are likely unreadable without MIME-aware tools.\r\n\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, snprintf(str, strsize - 1,
"--%s\r\nContent-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n", boundary); "--%s\r\nContent-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n", boundary);
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
} else { } else {
snprintf(str, strsize - 1, "Content-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n"); snprintf(str, strsize - 1, "Content-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
} }
/* analyze text for "." at beginning of line */ /* analyze text for "." at beginning of line */
@ -1235,6 +1261,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
for (index = 0; index < n_att; index++) { for (index = 0; index < n_att; index++) {
/* return proper Content-Type for file type */ /* return proper Content-Type for file type */
@ -1260,11 +1287,13 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, "Content-Transfer-Encoding: BASE64\r\n"); snprintf(str, strsize - 1, "Content-Transfer-Encoding: BASE64\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, snprintf(str, strsize - 1,
"Content-Disposition: attachment; filename=\"%s\"\r\n\r\n", "Content-Disposition: attachment; filename=\"%s\"\r\n\r\n",
@ -1272,6 +1301,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
/* encode file */ /* encode file */
strlcpy(file_name, lbs->data_dir, sizeof(file_name)); strlcpy(file_name, lbs->data_dir, sizeof(file_name));
@ -1303,6 +1333,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
} }
} }
@ -1311,18 +1342,22 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to,
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
snprintf(str, strsize - 1, "QUIT\r\n"); snprintf(str, strsize - 1, "QUIT\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (verbose) if (verbose)
fputs(str, stdout); fputs(str, stdout);
logf(lbs, str);
closesocket(s); closesocket(s);
free(str); free(str);