forwardemail.net icon indicating copy to clipboard operation
forwardemail.net copied to clipboard

Support optional SMTP\_HELO\_HOST to separate EHLO identity from WEB\_HOST

Open S4r4h-O opened this issue 7 months ago • 2 comments

Many self-hosted setups serve the web UI on a subdomain (for example, mail.example.com) while sending mail as the root domain (example.com). Today, adjusting that behavior requires a manual code change because the server always uses WEB_HOST (or DOMAIN) for both the UI and SMTP HELO/EHLO.

Suggested Approach We could introduce a new environment variable, SMTP_HELO_HOST. When set, the server would use it for the HELO/EHLO hostname; otherwise it would fall back to the existing WEB_HOST or DOMAIN.

Details

  • Code change in smtp-server.js Update the instantiation of SMTPServer so that the name option checks SMTP_HELO_HOST first:

    this.server = new SMTPServer({
    -  name: process.env.WEB_HOST || process.env.DOMAIN,
    +  name: process.env.SMTP_HELO_HOST || process.env.WEB_HOST || process.env.DOMAIN,
       // other options…
    });
    
  • Defaults and documentation In .env.defaults, document the new variable:

    # Optional HELO/EHLO hostname. Falls back to WEB_HOST or DOMAIN if unset.
    SMTP_HELO_HOST=
    

    Add a section to README.md explaining how to:

    1. Serve the UI on mail.example.com while advertising EHLO as example.com (by setting SMTP_HELO_HOST=example.com)
    2. Continue default behavior for single-host setups by leaving it blank

Benefits

  • Avoids manual patches for common self-hosted patterns
  • Keeps existing behavior unchanged for users who don’t set the new variable
  • Improves clarity in configuration and documentation

S4r4h-O avatar May 15 '25 17:05 S4r4h-O

Can you submit a PR for this?

titanism avatar May 16 '25 11:05 titanism

Can you submit a PR for this?

I'm not a JS person but I can try

S4r4h-O avatar May 16 '25 12:05 S4r4h-O