From 4473be5eaf35e3a1592c9e5a6e4828f72ccc4069 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Wed, 28 Nov 2018 16:24:09 +0100 Subject: [PATCH] Implemented SMTP port --- doc/config.html | 5 +++++ src/elogd.c | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/doc/config.html b/doc/config.html index 516c86f0..7dacae15 100755 --- a/doc/config.html +++ b/doc/config.html @@ -276,6 +276,11 @@ Welcome title = <img src="welcome.jpg"><p><font size=5 color=whit elogd -t <your password> +
  • + SMTP port = <port>
    + This defines the port under which the SMTP server is listening. The + default is 25, but some newer servers use port 587. +
  • Logfile = <file>
    This option specifies a filename which logs all login/logout activities diff --git a/src/elogd.c b/src/elogd.c index 4daab163..a746263d 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -2173,10 +2173,17 @@ int sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, char *text, c if (s == -1) return -1; - /* connect to remote node port 25 */ + strsize = MAX_CONTENT_LENGTH + 1000; + str = xmalloc(strsize); + + /* connect to remote node port on SMTP port */ + int smtp_port = 25; + if (getcfg(lbs->name, "SMTP port", str, strsize)) + smtp_port = atoi(str); + memset(&bind_addr, 0, sizeof(bind_addr)); bind_addr.sin_family = AF_INET; - bind_addr.sin_port = htons((short) 25); + bind_addr.sin_port = htons((short) smtp_port); phe = gethostbyname(smtp_host); if (phe == NULL) { @@ -2193,9 +2200,6 @@ int sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, char *text, c return -1; } - strsize = MAX_CONTENT_LENGTH + 1000; - str = xmalloc(strsize); - recv_string(s, str, strsize, 10000); if (get_verbose() >= VERBOSE_INFO) efputs(str); @@ -22671,7 +22675,7 @@ int compose_email(LOGBOOK * lbs, char *rcpt_to, char *mail_to, int message_id, */ if (status < 0) { - sprintf(str, loc("Error sending Email via \"%s\""), smtp_host); + sprintf(str, loc("Error sending Email via \"%s\""), smtp_host); if (error[0]) { strlcat(str, ": ", sizeof(str)); strlcat(str, error, sizeof(str)); @@ -22679,7 +22683,7 @@ int compose_email(LOGBOOK * lbs, char *rcpt_to, char *mail_to, int message_id, url_encode(str, sizeof(str)); sprintf(mail_param, "?error=%s", str); } else if (error[0]) { - sprintf(str, loc("Error sending Email via \"%s\""), smtp_host); + sprintf(str, loc("Error sending Email via \"%s\""), smtp_host); strlcat(str, ": ", sizeof(str)); strlcat(str, error, sizeof(str)); url_encode(str, sizeof(str));