Email discount code for friends after purchase

Shopify Partner
2 0 1

Hi! Could you please help me to find an app or describe how can I integrate this in liquid theme code?

I want to show popup after the purchase which allows to directly add email addresses, and this would trigger and automatic send letter on this emails  with a discount code.

I can create popup using js, but the main problem is how to send letters on the added email adresses with a discount code.