input: Write a function to send automated emails to a list of recipients. The function should take a list of email addresses as input, iterate over the list, and send an email to each address using Gmail's SMTP server. If the email is sent successfully, print "Email sent successfully." Otherwise, handle the error appropriately.
  assert send_automated_emails(["email1@example.com","email2@example.com"]) == print('Email sent successfully.')
  assert send_automated_emails(["email3@example.com","invalid_email"]) == print('Email sent failed.')
output: import smtplib
  from email.mime.text import MIMEText
  
  def send_automated_emails(recipients):
      sender_email = "your_email@gmail.com"
      sender_password = "your_password"
      subject = "Test Email"
      body = "This is a test email."
  
      for recipient in recipients:
          msg = MIMEText(body)
          msg['Subject'] = subject
          msg['From'] = sender_email
          msg['To'] = recipient
  
          try:
              with smtplib.SMTP('smtp.gmail.com', 587) as server:
                  server.starttls()
                  server.login(sender_email, sender_password)
                  server.sendmail(sender_email, recipient, msg.as_string())
              print("Email sent successfully.")
          except Exception as e:
              print("Email sent failed.")