capture the address to which the mail was sent to

Hello. I am working on a script for replying to mail. What I do not know now how to do is to capture the address to which the mail was sent to? I have multiple mail accounts, and I want to be able to control events to different scenarios depending on which of my accounts / email addresses were sent to?

For example,

The spam company sends an email to first@mymail.com. Then I want the script to respond “Stop sending spam to first@minmail.com”.
If the Spam company sends instead to second@mymail.com., the mail should send a reply with the text “Stop sending spam to second@mymail.com”.
It would be best if the mail could also be sent from the respective email address, but it seems difficult?

I’m not sure that responding to a spammer is a good idea.
If you do, he will know that your address is an active one.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 27 février 2020 12:37:24

Ok, you are right. But there are “good spammers” too, like mailists and stuff. Anyway, any ideas about the script?