Last active
September 16, 2019 23:32
-
-
Save sumanth232/fac107dfc4ebf5172069839f5eac6737 to your computer and use it in GitHub Desktop.
Email address permutations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
usage_message = ''' | |
Usage : | |
python email.py company 'firstname1 lastname1' 'firstname2 lastname2' .... | |
''' | |
def get_email_address_permutations(first_name, last_name, company): | |
first_name = first_name.lower() | |
last_name = last_name.lower() | |
company = company.lower() | |
addresses = [ | |
'{}{}@{}.com'.format(first_name, last_name[0], company), | |
'{}{}@{}.com'.format(first_name[0], last_name, company), | |
'{}.{}@{}.com'.format(first_name, last_name, company), | |
'{}{}@{}.com'.format(first_name, last_name, company), | |
# Reverse of these addresses | |
'{}{}@{}.com'.format(last_name[0], first_name, company), | |
'{}{}@{}.com'.format(last_name, first_name[0], company), | |
'{}.{}@{}.com'.format(last_name, first_name, company), | |
'{}{}@{}.com'.format(last_name, first_name, company) | |
] | |
return addresses | |
# parse command line arguments | |
email_addresses = [] | |
company = sys.argv[1].lower() | |
print(os.linesep) | |
print('Recruiter names parsed : ') | |
print('----------------------') | |
for name in sys.argv[2:]: | |
first_name, last_name = name.split(' ') | |
print('{} {}'.format(first_name, last_name)) | |
email_addresses.extend(get_email_address_permutations(first_name, last_name, company)) | |
print(os.linesep) | |
print('--- Put the rest in BCC, except the first one ---') | |
print('-------------------------------------------------' + os.linesep) | |
for address in email_addresses: | |
print(address) | |
print(os.linesep) | |
print('#####################################################################') | |
print('#### IMPORTANT - PUT THE ADDRESSES in BCC, except the first one #####') | |
print('#####################################################################') | |
print(os.linesep) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment