You may want to broaden your perspective a bit when people make suggestions.

Karsten did not spell out a full design and should not need to.

But consider this as a scenario.

You want to send (almost) the same message to one or more recipients.

So call a program, perhaps some variant on a shell script, that does some
prep work such as maybe creating a temporary or working directory/folder.
Had one copy of your message ready in a file somewhere, Have a way to get a
list of recipients intended and the file or files containing enough info to
link email addresses to human names and anything else such as their
preferred pronoun  or address.

Now have the script call your super-duper python program with enough info so
it can find the folder to put amended COPIES of your letter into as well as.
Perhaps the email address intended in the filename or whatever works for

Your program will then simply identify each email recipient you want and
look up the other info and prepend the customized salutation, or make
substitutions in the template and write out a new file in the designated
folder with perhaps the email address as the filename.

When your loop ends, exit the python program with success, or perhaps report
some failure.

The shell script now resumes by checking the exit status and if OK,
continuing to enter the folder and loop on all file contests and invoke the
functionality to send each copied/enhanced file to the intended recipient.
If you also need to support attachments, you can figure out how to attach
the same ones to each as I assume those are not changed for each recipient. 

It may keep track of how many worked or failed and eventually clear out the
files and perhaps the folder and you are done.

This is NOT a required way to do it but for what sounds like a limited
personal project, it should work well enough and have you do the limited
amount of work you need in Python.

Having said that, you can likely also easily do everything without python
and I have written some huge shell scripts in my time to do way more complex
things. But learning how to do things like this well in python can be time
well spent as long as you don't tackle too much at a time and get

-----Original Message-----
From: Python-list <> On
Behalf Of Rich Shepard via Python-list
Sent: Tuesday, January 30, 2024 12:53 PM
Subject: Re: Aw: Re: Extract lines from file, add to new files

On Tue, 30 Jan 2024, Karsten Hilbert wrote:

> Why not foxus on just the part you think you are better off using python,
> namely personalization ?
> Create personalized files and send them with your trusted mailx solution ?


Too much time. And while mailx accepts the '-a' option for attachments but
has none for individual salutations.




Reply via email to