as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
create a script that sends out automatic email notifications to customers.
user
the script should contain the following sections: 

1. a check to see if customers have opted-in to the service.
2. a loop to iterate through each customer’s email address. 
3. a method to construct and format the email. 
4. a method to send out the automated email notification. 
5. a section for any error handling.
assistant