Your true origin IP can be retrieved, but only from an external source afaik. That's why I run ip.thaddy.com and ip.thaddy.com/simple.php
ip.thaddy.com resolves ip including forwarding (the innermost exposed ip) and ip.thaddy.com/simple.php returns the ip without forwarding (the outermost exposed ip).
The returned value is not a html page, but a string that you can immediately use in your sourcecode.
I can do this for other protocols than http(s) too, so can I set it up for email as well. (Basically running a client protocol serverside that analyses full headers, same as I do above, and perform a reverse lookup)
Also note this mechanism does not work for all possible situations. Returning local ip on the network is ofcourse not covered here. That needs to be resolved on network level.
The above enables you to obtain the ip's. You have to enable some passthrough to change the origin IP yourself, which can be done with a reverse proxy for example.
Or do you want to spoof the origin?
See:
https://lifehacker.com/how-spammers-spoof-your-email-address-and-how-to-prote-1579478914You can use both Indy and Synapse for the smtp server code.
Nowadays it is rather futile. I got this at my CEH exams.