EXIM4 paniclog (Ubuntu 22.04)

Hello,

I am running an Ubuntu 22.04 server with the HestiaCP panel and have been experiencing a persistent issue with email forwarding for approximately four months.

The problem specifically relates to forwarding server emails to my personal Gmail accounts. While most emails are successfully forwarded, I occasionally miss 1-2 emails, and my Exim4 paniclog is constantly being filled with the following error:

2025-11-29 20:25:03 1vMfBH-003nRZ-36 == personalmail @gmail.com root @srv.server.com R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${srs_encode {${readfile{/etc/exim4/srs.conf}}} {$return_path} {$original_domain}}”: empty address

2025-11-29 20:25:03 1vLwEB-002SUD-Bo == personalmail @gmail.com root @srv.server.com R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${srs_encode {${readfile{/etc/exim4/srs.conf}}} {$return_path} {$original_domain}}”: empty address

Note: I have already attempted to modify the Exim configuration files manually, but the issue persists.

Hi @tothattila05

What did you try?

Anyway, try this, in /etc/exim4/exim4.conf.template replace this:

  return_path = ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}

with this:

  return_path = ${if eq{$return_path}{}{$return_path}{${srs_encode{SRS_SECRET}{$return_path}{$sender_address_domain}}}}

Restart exim and try again:

systemctl restart exim4

Thank you for the suggestion/answer. I had already tried several methods where I conditionally set the Return-Path, but all of them resulted in an error. I’ve just tested the solution you provided, but unfortunately, it is also not working, and I am receiving the following error:

2025-11-29 23:58:53 1vMfBH-003nRZ-36 == user @gmail.com <root @srv1.server.com> R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${if eq{$return_path}{}{$return_path}{${srs_encode{${readfile{/etc/exim4/srs.conf}}}{$return_path}{$sender_address_domain}}}}”: empty address

2025-11-29 23:58:53 1vLwEB-002SUD-Bo == user @gmail.com <root @srv1.server.com> R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${if eq{$return_path}{}{$return_path}{${srs_encode{${readfile{/etc/exim4/srs.conf}}}{$return_path}{$sender_address_domain}}}}”: empty address

And this one?

return_path = ${if and {{!eq{$return_path}{}}{match{$return_path}{*@*}}} {${srs_encode{SRS_SECRET}{$return_path}{$sender_address_domain}}} {$return_path}}

Now i got this logs:

2025-11-30 00:36:58 1vOqbh-004wPj-Kx == user @gmail.com <root @srv1.server.com> R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${if and {{!eq{$return_path}{}}{match{$return_path}{@}}} {${srs_encode{${readfile{/etc/exim4/srs.conf}}}{$return_path}{$sender_address_domain}}} {$return_path}}”: empty address
2025-11-30 00:36:58 1vLwEB-002SUD-Bo == user @gmail.com <root @srv1.server.com> R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${if and {{!eq{$return_path}{}}{match{$return_path}{@}}} {${srs_encode{${readfile{/etc/exim4/srs.conf}}}{$return_path}{$sender_address_domain}}} {$return_path}}”: empty address

Then, I’m sorry but I don’t know how to fix it :frowning:

No problem, thanks for your time!

1 Like

Hi. Though I am not sure this may help: Re: [exim] 4.96-RC1 srs issue

Maybe you can go through this once.

These Too: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=290956

Sorry, if you have done so already.

Unfortunately, I’ve already reviewed the posts linked by @nu01 . The underlying problem here is that for certain mail submissions, such as the one achieved with the following trigger command:

/usr/bin/printf “This is the message body.\n” | /usr/bin/mail -v -r “[email protected]” -s “Cron <root@srv1>” [email protected]

The return path is empty for these messages, even when checking the following variables: return_path, primary_hostname, sender_address, and sender_address_domain (listed again for emphasis).

The solution is to provide a fixed postmaster variable and a primary domain as a fallback. Specifically, if all four of these variables are empty, the system should use a fixed postmaster address. This ensures that similar emails (e.g., from cron jobs) are delivered without error and avoids the “empty return path” failure.

The issue is not observed with the following configuration snippet:

return_path = ${srs_encode {SRS_SECRET} \
  {${if and{ {def:return_path} {!eq{$return_path}{}} } \
      {$return_path} \
      {${if and{ {def:sender_address} {!eq{$sender_address}{}} } \
          {$sender_address} \
          {postmaster@$primary_hostname} \
      }} \
  }} \
  {${if and{ {def:original_domain} {!eq{$original_domain}{}} } \
      {$original_domain} \
      {${if and{ {def:sender_address_domain} {!eq{$sender_address_domain}{}} } \
          {$sender_address_domain} \
          {$primary_hostname} \
      }} \
  }} \
}

In my specific case, the issue is completely resolved by using root@$primary_hostname as the fixed fallback address instead of postmaster@$primary_hostname. This configuration has been thoroughly tested with various email sending methods.

2 Likes

Could you please check whether this “simplified” conf works fine?

return_path = ${srs_encode {SRS_SECRET} \
  {${if def:return_path {$return_path} {${sender_address:-postmaster@$primary_hostname}}}} \
  {${if def:original_domain {$original_domain} {${sender_address_domain:-$primary_hostname}}}} \
}

With this version, i got these error:

LOG: MAIN PANIC == @gmail.com [email protected] R=dnslookup T=remote_forwarded_smtp defer (-1): Failed to expand return path “${srs_encode {${readfile{/etc/exim4/srs.conf}}} {${if def:return_path {$return_path} {${sender_address:-root@$primary_hostname}}}} {${if def:original_domain {$original_domain} {${sender_address_domain:-$primary_hostname}}}} }”: unknown expansion operator “sender_address”

1 Like