def _send_email(self, from_addr, to_addr, subject, msg, attach=None):
        """Send an email.

        Take a 'from' and 'to' addresses, a subject and the content, creates
        the email and send it.

        :param: from_addr (string) the address of the sender.
        :param: to_addr (string) the address of the recipient.
        :param: subject (string) the subject of the email.
        :param: msg (string) the content of the email.
        :param: attach (string) the path of the mirrors list.

        """
        email_obj = self._create_email(from_addr, to_addr, subject, msg)

        if(attach):
            # for now, the only email with attachment is the one for mirrors
            try:
                part = MIMEBase('application', "octet-stream")
                part.set_payload(open(attach, "rb").read())
                Encoders.encode_base64(part)

                part.add_header(
                    'Content-Disposition',
                    'attachment; filename="mirrors.txt"'
                )

                email_obj.attach(part)
            except __HOLE__ as e:
                raise SendEmailError('Error with mirrors: %s' % str(e))

        try:
            s = smtplib.SMTP("localhost")
            s.sendmail(from_addr, to_addr, email_obj.as_string())
            s.quit()
        except smtplib.SMTPException as e:
            raise SendEmailError("Error with SMTP: %s" % str(e))
dataset/ETHPy150Open TheTorProject/gettor/gettor/smtp.py/SMTP._send_email