def clean_recipients(self, email_message):
new_recipients = []<EOL>recipients = [sanitize_address(addr, email_message.encoding)<EOL>for addr in email_message.recipients()]<EOL>for recipient in recipients:<EOL><INDENT>if self.matches_whitelist(recipient):<EOL><INDENT>new_recipients.append(recipient)<EOL><DEDENT>elif settings.EMAIL_BACKEND_REROUTE_BLACKLIST:<EOL><INDENT>for name, addr in settings.TEST_EMAIL_BACKEND_RECIPIENTS:<EOL><INDENT>new_recipients.append(addr)<EOL><DEDENT><DEDENT><DEDENT>new_recipients = list(set(new_recipients))<EOL>return new_recipients<EOL>
Removes all the unallowed recipients.