DAX_MAX wrote:
Do you have any insight on creating the AppleScript? That is what I need at the moment, as the other change may not be possible for some time.
You’ll need a different mail client, then. There’s no means—no hook and no API—provided to rewrite the SMTP headers within the Apple Mail client data store on macOS or on other Apple platforms.
The web server sets the SMTP headers involved here.
Which means fixing the web server to write the headers as required, or using a different mail client or mail transfer app that can process mail arriving via that mail account into some local mail clients or—preferably—into the customer relationship management (CRM) system or whatever app or package is where these mail messages are arriving at—and re-write the headers at that transfer.
The IMAPSYNC tool is in this general area, and there are php, Python, Perl and other apps that can read and process mail messages; that can be mail clients. This tool would replace the existing mail client, and rework the headers. And it can be somewhat fragile without some supporting mechanisms such as using launchd script or such for startup, as it would need to be running all the time. But AppleScript just isn’t set up to be a mail client.
It’s likely also possible to get Postfix or another mail server to rewrite the mail headers, but that access into the mail server probably isn’t available. If the CRM can’t do this, this is probably the second easiest.
Easiest fix here is that web server.