I have a python program that sends email to muliple recipients with multiple attachments(it takes all the pdf files in a folder and sends the email). Now I want to do this
my folder contains
file1.pdf file2.pdf file3.pdf file4.pdf file5.pdf file6.pdf.....
I have a text file that would contain the name, emailid and list of files to be attached
recipient1 [email protected] file1.pdf file2.pdf file3.pdf file4.pdf
recipient2 [email protected] file2.pdf file3.pdf
recipient3 [email protected] file1.pdf file2.pdf
def get_contacts(filename):
names = []
emails = []
with open(filename, mode='r', encoding='utf-8') as contacts_file:
for a_contact in contacts_file:
names.append(a_contact.split()[0])
emails.append(a_contact.split()[1])
return names, emails
I am using the above code to read a text file and get the name and email id of the recipient, Can I use a similar way to read the files to be attached to the each recipient