Skip to content

Commit

Permalink
move campaign id checks to separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
schwartzadev committed Jan 5, 2020
1 parent 727fc27 commit fe5b396
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions audit_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,43 @@ def check_if_string_from_sender(check_string, email_message):
return check_string.lower() in email_message['from'].lower()


conn = connect_to_email()

for index, row in candidates.iterrows():
if row['successful_registration'] == True: # already documented
count, email_ids = check_campaign_emails_by_id(conn, row['campaign_id'])
for eid in email_ids:
# print(row['name'], ' ', count, 'emails found')
email_content = get_email_by_email_id(conn, eid)

web_domain = clean_website_url(row['website'])
is_from_domain = check_if_string_from_sender(
web_domain,
email_content['message']
)

if not is_from_domain: # does the sender match the campaign website?
print(
'WARNING: no domain match:',
row['name'],
row['campaign_id'],
email_content['message']['from'],
' domain:',
def check_emails_by_campaign_id():
"""
checks that emails are going to the right email ID
intended to confirm that each candidate is registered with their proper [email protected] ID
"""
conn = connect_to_email()

for index, row in candidates.iterrows():
if row['successful_registration'] == True: # already documented
count, email_ids = check_campaign_emails_by_id(conn, row['campaign_id'])
for eid in email_ids:
# print(row['name'], ' ', count, 'emails found')
email_content = get_email_by_email_id(conn, eid)

web_domain = clean_website_url(row['website'])
is_from_domain = check_if_string_from_sender(
web_domain,
'name check:',
[check_if_string_from_sender(n, email_content['message']) for n in row['name'].split()]
email_content['message']
)

# todo add checks to confirm the proper campaign id
if not is_from_domain: # does the sender match the campaign website?
print(
'WARNING: no domain match:',
row['name'],
row['campaign_id'],
email_content['message']['from'],
' domain:',
web_domain,
'name check:',
[check_if_string_from_sender(n, email_content['message']) for n in row['name'].split()]
)
try:
conn.close()
except:
pass
conn.logout()


try:
conn.close()
except:
pass
conn.logout()
if __name__ == '__main__':
check_emails_by_campaign_id()

0 comments on commit fe5b396

Please sign in to comment.