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:
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:
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:
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.