input: Write a function to send automated emails by taking a list of email addresses as input and iterating over the list to send an email to each address. Ensure that the function correctly uses smtplib to connect to an email server and sends the email along with subject and message body for each recipient. If the email is sent successfully, print 'Email sent successfully.'
  
  
  def send_automated_emails(recipient_emails):
      import smtplib
      
      sender_email = 'example@gmail.com'
      password = 'example_password'
      
      for email in recipient_emails:
          with smtplib.SMTP('smtp.gmail.com', 587) as server:
              server.ehlo()
              server.starttls()
              server.login(sender_email, password)
  
              subject = 'Automated Email from Program'
              message = 'Message body'
              
              server.sendmail(sender_email, email, 'Subject: ' + subject + '\n\n' + message)
              server.quit()
              print('Email sent successfully.')
              
  assert send_automated_emails(["email1@example.com","email2@example.com"])
  
output: 
  def send_automated_emails(recipient_emails):
      import smtplib
      
      sender_email = 'example@gmail.com'
      password = 'example_password'
      
      for email in recipient_emails:
          with smtplib.SMTP('smtp.gmail.com', 587) as server:
              server.ehlo()
              server.starttls()
              server.login(sender_email, password)
  
              subject = 'Automated Email from Program'
              message = 'Message body'
              
              server.sendmail(sender_email, email, 'Subject: ' + subject + '\n\n' + message)
              server.quit()
              print('Email sent successfully.')
  