Fossil Forum

Alerts via SMTP relay try to send e-mail address in EHLO

Alerts via SMTP relay try to send e-mail address in EHLO

Alerts via SMTP relay try to send e-mail address in EHLO

(1) By aitap on 2020-08-13 13:33:46 [source]

Hi everyone,

Either I seriously misunderstand the /setup_notification page, or there is a bug:

$ $fossil version # freshly built from tag version-2.11.1
This is fossil version 2.11.1 [307d94c549] 2020-06-08 19:48:29 UTC
$ echo foo > bar
$ $fossil alert test-message me@redacted.tld --body bar --smtp-trace --subject Hello -R repo.fossil
S: 220 mx.redacted.tld Microsoft ESMTP MAIL Service ready at Thu, 13 Aug 2020 16:07:17 +0300
C: EHLO me@redacted.tld # <-- delay of a few seconds after this line
S: 501 5.5.4 Invalid domain name
S: 221 2.0.0 Service closing transmission channel
Sending email

I think that alerts.c passes the wrong arguments to smtp_session_new(). In alert_sender_new(), p->zFrom is the sender's e-mail address, while smtp_session_new() expects its zFrom argument to be a domain name.

While preparing a patch addressing this (which is far from ideal, but may be fair given the information available to alerts.c: just assume the domain name of the sender, like we assume we are allowed to send e-mails from sender's address), I realised that I am not dealing with an open relay, so I'll have to use a different configuration.

Nevertheless, here is a diff:

Index: src/alerts.c
--- src/alerts.c
+++ src/alerts.c
@@ -524,11 +524,11 @@
     const char *zRelay = 0;
     emailerGetSetting(p, &zRelay, "email-send-relayhost");
     if( zRelay ){
       u32 smtpFlags = SMTP_DIRECT;
       if( mFlags & ALERT_TRACE ) smtpFlags |= SMTP_TRACE_STDOUT;
-      p->pSmtp = smtp_session_new(p->zFrom, zRelay, smtpFlags);
+      p->pSmtp = smtp_session_new(smtp_domain_of_addr(p->zFrom), zRelay, smtpFlags);
   return p;

Index: src/smtp.c
--- src/smtp.c
+++ src/smtp.c
@@ -580,11 +580,11 @@
 ** The input is a base email address of the form "local@domain".
 ** Return a pointer to just the "domain" part.
-static const char *domainOfAddr(const char *z){
+const char *smtp_domain_of_addr(const char *z){
   while( z[0] && z[0]!='@' ) z++;
   if( z[0]==0 ) return 0;
   return z+1;
@@ -625,16 +625,16 @@
   if( g.argc<5 ) usage("EMAIL FROM TO ...");
   blob_read_from_file(&body, g.argv[2], ExtFILE);
   zFrom = g.argv[3];
   nTo = g.argc-4;
   azTo = (const char**)g.argv+4;
-  zFromDomain = domainOfAddr(zFrom);
+  zFromDomain = smtp_domain_of_addr(zFrom);
   if( zRelay!=0 && zRelay[0]!= 0) {
     smtpFlags |= SMTP_DIRECT;
     zToDomain = zRelay;
-    zToDomain = domainOfAddr(azTo[0]);
+    zToDomain = smtp_domain_of_addr(azTo[0]);
   p = smtp_session_new(zFromDomain, zToDomain, smtpFlags, smtpPort);
   if( p->zErr ){
     fossil_fatal("%s", p->zErr);

Hope this helps!

(2) By absc (abiscuola) on 2021-07-05 21:48:29 in reply to 1 [link] [source]


I just installed fossil 2.16 and I have the same problem.

My fossil server is running on OpenBSD under an httpd(8) chroot and I have my MTA that accept local e-mails on

The fossil smtp client, tries to use the configured e-mail address as an EHLO command, getting the the error already mentioned by aitap.

Would it be possible to have a separate property to set an EHLO, acceptable by a modern MTA?


(3) By Richard Hipp (drh) on 2021-07-05 23:06:15 in reply to 2 [link] [source]

Does your patch clear the problem?

(4) By Pietro Cerutti (gahr) on 2023-03-02 07:16:40 in reply to 3 [link] [source]

Not the OP, but I confirm that the patch is correct: EHLO must be a host name, not an email address.

I have just upgraded the FreeBSD port of fossil to 2.21 and I have incorporated this patch.

It would be nice to have this upstreamed. Thanks!

(5) By Stephan Beal (stephan) on 2023-03-02 10:28:00 in reply to 4 [link] [source]

I have just upgraded the FreeBSD port of fossil to 2.21 and I have incorporated this patch.

Can you please confirm for us whether the smtp-ehlo branch resolves the problem for you?

(6) By Pietro Cerutti (gahr) on 2023-03-03 14:17:19 in reply to 5 [link] [source]

It does, thanks!