For your customers to receive an email when an out-of-stock item comes back in stock, you need two things:
#1 An email template called in_stock_mail.html in your theme.
#2 A form on your product page.
The form itself looks like this
How to do it. To do the above, you need to implement the following in your theme:
<form action="" method="post">
<input type="hidden" name="out_of_stock_signup" value="1"/>
<input type="hidden" name="product_id" value="<{$product->getProductId()}>"/>
<input type="email" name="email" placeholder="Your email address"/>
<label>
<input type="checkbox" name="newsletter" value="1"/>
Also subscribe to newsletter
</label>
<input type="submit" value="Subscribe"/>
</form>
The out_of_stock_signup, product_id and email fields are important in the above.
If you want to receive the variant you need to include the attribute_value_id field which is the ID of the variant.
When your product is in stock, the email is sent from the in_stock_mail.html template. If you use variants, the name of the variant will be in the $variant_name variable.
You can see who is subscribed to the email from the product overview in admin.