When a product is sold out, customers can use the Back in Stock notification form to leave their email. Once the item is restocked, you can let them know it’s available again.

Your product must be out of stock, and please do not enable "Continue selling when out of stock".

When a customer submits the Back in Stock form, a message will be sent to the sender email you’ve set up in Shopify under Settings > Notifications > Sender email. When the product is available again, you can then email the customer to let them know.

This process is not automatic. When the product comes back in stock, you’ll need to manually email the customer using the address they provided. If you want this process to run automatically, you might consider using a third-party app from the Shopify App Store.