def sendmail(self, info, logfile=[], mailsubject="DNS Hijack Monitor Alert"):
        msg = MIMEMultipart()
        bodytext = "\n".join(x for x in info)
        logtext = "\n".join(x for x in logfile)
        mailbody = MIMEText(bodytext, 'plain')
        msg.attach(mailbody)

        msg['Subject'] = '%s - %s' % (gethostname(), mailsubject)
        msg['From'] = self.fromaddress
        # uncomment the next line if you don't want return receipts
        msg['Disposition-Notification-To'] = self.fromaddress
        msg['To'] = self.to
        msg['X-Priority'] = '2'

        if len(logfile) > 0:
            part = MIMEBase('application', "octet-stream")
            part.set_payload(logtext)
            Encoders.encode_base64(part)
            part.add_header('Content-Disposition', 'attachment; filename="dnshjmon.txt"')
            msg.attach(part)
        noerror = False
        thistimeout = 5
        while not noerror:
            try:
                print (self.server, self.port) % "[+] Connecting to %s on port %d"
                s = smtplib.SMTP(self.server, self.port, 'minicase', self.timeout)
                print "[+] Connected"
                if self.usetls:
                    print "[+] Issuing STARTTLS"
                    s.starttls()
                    print "[+] STARTTLS established"
                if self.requirelogin:
                    print "[+] Authenticating"
                    s.login(self.login, self.password)
                    print "[+] Authenticated"
                print "[+] Sending email"
                s.sendmail(self.to, [self.to], msg.as_string())
                print "[+] Mail sent, disconnecting"
                s.quit()
                noerror = True
            except smtplib.SMTPServerDisconnected as e:
                print "     ** ERROR, Server disconnected unexpectedly"
                print "        This is probably okay"
                noerror = True
            except smtplib.SMTPResponseException as e:
                print "     ** ERROR Server returned %s : %s" % (str(e.smtp_code), e.smtp_error)
            except smtplib.SMTPSenderRefused as e:
                print "     ** ERROR Sender refused %s : %s" % (str(e.smtp_code), smtp_error)
            except smtplib.SMTPRecipientsRefused as e:
                print "     ** ERROR Recipients refused"
            except smtplib.SMTPDataError as e:
                print "     ** ERROR Server refused to accept the data"
            except smtplib.SMTPConnectError as e:
                print "     ** ERROR establishing connection to server"
            except smtplib.SMTPHeloError as e:
                print "     ** ERROR HELO Error"
            #except smtplib.SMTPAUthenticationError as e:
            #    print "     ** ERROR Authentication"
            except smtplib.SMTPException as e:
                print "     ** ERROR Sending email"
            except:
                print "     ** ERROR Unable to send email !"

            if not noerror:
                print "     I'll try again in %d seconds" % thistimeout
                time.sleep(thistimeout)
                if thistimeout < 1200:
                    thistimeout += 5
        return


# ----- main routine -----
dataset/ETHPy150Open corelan/dnshjmon/dnshjmon.py/Mailer.sendmail/swapped operands of `%`