Given a list of names and a second list of email addresses, this script sorts the person to whom each of the participants has to buy the gift, and emails the name to each person.
A function is defined to check that nobody draws his own name.
Note that a sending email is needed; in particular, the script works for a gmail server and it's necessary to allow the "Less Secure App access" in the settings of the account.