Esempio n. 1
0
	def get_certemailaddresses(self,certfile):
		"""returns a list of all e-mail addresses the 'certfile' for which
		is valid."""
		cmd=[   self.parent._SMIMECMD,
				"x509",
				"-in",certfile,
				"-text",
				"-noout"]
		cert,returncode=self._opensslcmd(" ".join(cmd))
		cert=cert.decode("utf-8",unicodeerror)
		email=[]
		found=re.search("(?<=emailAddress=)(.*)",cert)

		if found != None:

			try:
				email.append(cert[found.start():found.end()])
			except:
				pass

		found=re.search("(?<=email:)(.*)",cert) # get alias names

		if found != None:

			try:
				n=cert[found.start():found.end()]
				if n not in email:
					email.append(n)
			except:
				pass

		return email
Esempio n. 2
0
def send_email(content, titles):
    # 读取config.json配置发信者信息及收信者信息
    with open('config.json', 'r') as f:
        data = json.load(f)
    mail_host = data['host']
    mail_user = data['user']
    mail_password = data['password']
    sender = data['sender']
    receivers = data['receivers']
    email = []
    for i in range(len(content)):
        message = MIMEText(content[i], 'html', 'utf-8')
        message['From'] = sender
        message['To'] = ','.join(receivers)
        message['Subject'] = titles[i]
        email.append(message)
    try:
        smtpObj = smtplib.SMTP_SSL(mail_host, 465)
        smtpObj.login(mail_user, mail_password)
        for message in email:
            smtpObj.sendmail(sender, receivers, message.as_string())
            title = message['Subject']
            log(f'[INFO]:推送通知“{title}”成功')
        smtpObj.quit()
    except smtplib.SMTPException as e:
        log(f'[error]:{e}')
	def get_certemailaddresses(self,certfile):
		"""returns a list of all e-mail addresses the 'certfile' for which
		is valid."""
		cmd=[   self.parent._SMIMECMD,
				"x509",
				"-in",certfile,
				"-text",
				"-noout"]
		cert,returncode=self._opensslcmd(" ".join(cmd))
		cert=cert.decode("utf-8",unicodeerror)
		email=[]
		found=re.search("(?<=emailAddress=)(.*)",cert)

		if found != None:

			try:
				email.append(cert[found.start():found.end()])
			except:
				pass

		found=re.search("(?<=email:)(.*)",cert) # get alias names

		if found != None:

			try:
				n=cert[found.start():found.end()]
				if n not in email:
					email.append(n)
			except:
				pass

		return email
def get_contacts(people):
    """
    @author: byoung
    """
    total = []
    names = []
    email = []
    message = []
    text = "Happy New Year"
    # Get names, emails and msg
    for i in people:
      names.append(i.name)
      email.append(i.email)
      message.append(str(i))
      total.append([names[-1], email[-1], message[-1]])
    return total
Esempio n. 5
0
    def parse_messages(self, message):
        emails = [e.strip() for e in re.split(r'On.+wrote:|From:.+', message) if
                  "Begin forwarded message:" not in e.strip() and "Forwarded message" not in e]
        froms = re.findall(r'On.+wrote:|From:.+', message)

        froms = froms
        messages = []
        for i in range(0, len(emails)):
            message = Message()

            meta = self.parse_meta_v3(froms[i] + "\n" + emails[i])


            # print(message.content)
            # print("+++++++++++++++++++++++++++++++++")
            if meta is not None:
                message.sender_name = meta["name"]
                message.sender_address = meta["email"]
                message.time = meta["time"]
            messages.append(message)

            lines = emails[i].splitlines()
            email = []
            for line in lines:
                if line.strip() == "":
                    continue
                if line.startswith(('From', 'To', 'Sent', 'Date', 'Subject', 'Cc', 'Received')):
                    # print(line)
                    email = []
                # elif line.strip().lower() == message.sender_name.lower() or line.strip().lower() == message.sender_name.split()[0].lower():
                elif line.strip().lower() in message.sender_name.lower():
                    email.append(line)
                    break
                else:
                    email.append(line)

            # message.content = re.sub(r'(From|To|Sent|Date|Subject|Cc|Received):.+', '', emails[i], re.MULTILINE).strip()
            message.content = "\n".join(email)
            message.keywords = nlp.keywords_from_text(message.content)
        messages.reverse()
        return messages
Esempio n. 6
0
def final_csv():
	df = pd.read_csv('email_details_3.csv')
	# print(df)
	name = []
	email = []
	date = []
	subject = []
	for index, row in df.iterrows():
		details = str(row['From'])
		print((details))
		if details!='nan':
			x = details.find('<')
			na = details[0:x-1]
			em = details[x+1:-1]
			name.append(na)
			email.append(em)
		else:
			name.append('')
			email.append('')
		date.append(row['Date'])
		subject.append(row['Subject'])
	dfdata = {'Sender Email': email, 'Sender Name': name, 'Date': date, 'Subject': subject}
	dfnew = pd.DataFrame(dfdata)
	dfnew.to_csv('email_details_10.csv')
Esempio n. 7
0
def get_email(bucket, fileName):
    s3 = boto3.client("s3")
    file = s3.get_object(Bucket=bucket, Key=fileName)
    content = file["Body"].read().decode('utf-8')
    subject = content.split('Subject: ')[1]
    subject = subject.split('\n')[0]

    edate = content.split('Date: ')[1]
    edate = edate.split('\n')[0]

    sender = content.split('Return-Path: <')[1]
    sender = sender.split('>')[0]
    sender.split()
    email = []
    email.append(subject)
    email.append(edate)
    email.append(sender)
    print(subject, edate, sender)
    return email
Esempio n. 8
0
def test_email_list(query):
    email = []
    for i in range(2000):
        email.append( query % ( hashlib.sha1(str(random.random())).hexdigest(), ))
    return email
Esempio n. 9
0
""" LDA on top of TF-IDF"""
# use this when starting here and want to start with cleaned filtered dataset
really_good_df = pd.read_excel("final_cleaned_data_v2.xlsx")

# # use this if you are continuing from part 6 and above
# really_good_df = sample

temp = really_good_df.newcontent.dropna()
emails = list(temp)

# Remove punctuation
email = [ ]

punc = string.punctuation.replace( '-', '' )
for i in range( 0, len( emails ) ):
    email.append( re.sub( '[' + punc + ']+', '', emails[ i ] ) )
        

# Porter stem
porter_lda = nltk.stem.porter.PorterStemmer()
stems_lda = { }

for i in range( 0, len( email ) ):
    tok = email[ i ].split()
    for j in range( 0, len( tok ) ):
        if tok[ j ] not in stems_lda:
            stems_lda[ tok[ j ] ] = porter_lda.stem( tok[ j ] )
        tok[ j ] = stems_lda[ tok[ j ] ]

    email[ i ] = ' '.join( tok )
Esempio n. 10
0
    def trigger(self):
        email = []
        mess = self.message
        email.append(format(mess['message-id']))

        timefloat = time.mktime(parsedate(mess['date']))
        timestamp = str(timefloat)
        email.append(timestamp)

        email.append(format(mess['from']))
        email.append(format(mess['to']))
        email.append(format(mess['cc']))
        email.append(format(mess['subject']))
        email.append(format(mess['in-reply-to']))

        for part in mess.walk():
            if part.get_content_type() == 'text/plain':
                body = strip_string(str(part.get_payload()))
                email.append(body)
            else:
                continue

        if len(email) < 8:
            email.append('')

        f = feature(email)
        predicted = regr.predict([f])[0]
        draft_time(email, predicted / 3600)
Esempio n. 11
0
	def trigger(self):
		email = []
		mess = self.message
		email.append(format(mess['message-id']))

		timefloat = time.mktime(parsedate(mess['date']))
		timestamp = str(timefloat)
		email.append(timestamp)

		email.append(format(mess['from']))
		email.append(format(mess['to']))
		email.append(format(mess['cc']))
		email.append(format(mess['subject']))
		email.append(format(mess['in-reply-to']))

		for part in mess.walk():
			if part.get_content_type() == 'text/plain':
				body = strip_string(str(part.get_payload()))
				email.append(body)
			else:
				continue

		if len(email) < 8:
			email.append('')

		f = feature(email)
		predicted = regr.predict([f])[0]
		draft_time(email, predicted/3600)