def get_attachments_by_name(self, name, check_regex, find_first=False):
attachments = []<EOL>for part in self.mail.walk():<EOL><INDENT>mail_part = MailPart(part)<EOL>if mail_part.is_attachment():<EOL><INDENT>found_attachment = mail_part.has_matching_name(name) if check_regexelse mail_part.has_equal_name(name)<EOL>if found_attachment:<EOL><INDENT>file_name, file_payload = mail_part.get_file()<EOL>self.log.info('<STR_LIT>'.format(file_name))<EOL>attachments.append((file_name, file_payload))<EOL>if find_first:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return attachments<EOL>
Gets all attachments by name for the mail.

:param name: The name of the attachment to look for.
:type name: str
:param check_regex: Checks the name for a regular expression.
:type check_regex: bool
:param find_first: If set to True it will only find the first match and then quit.
:type find_first: bool
:returns: a list of tuples each containing name and payload
          where the attachments name matches the given name.
:rtype: list of tuple