• Aw: Re: Extract lines from file, add to new files

    From Karsten Hilbert@3:633/280.2 to All on Wed Jan 31 04:34:01 2024
    For 30 years I've used a bash script using mailx to send messages to a list of recipients. They have no salutation to personalize each one. Since I want to add that personalized salutation I decided to write a python script to replace the bash script.

    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 ?

    That'll take out wrestling with smptlib et al.

    Karsten


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Rich Shepard@3:633/280.2 to All on Wed Jan 31 04:53:24 2024
    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 ?

    Karsten,

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

    Regards,

    Rich

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From avi.e.gross@gmail.com@3:633/280.2 to All on Wed Jan 31 08:46:13 2024
    Rich,

    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
    you.

    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
    overwhelmed.




    -----Original Message-----
    From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of Rich Shepard via Python-list
    Sent: Tuesday, January 30, 2024 12:53 PM
    To: python-list@python.org
    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 ?

    Karsten,

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

    Regards,

    Rich
    --
    https://mail.python.org/mailman/listinfo/python-list


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Mats Wichmann@3:633/280.2 to All on Wed Jan 31 09:18:20 2024
    On 1/30/24 14:46, AVI GROSS via Python-list wrote:
    Rich,

    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.

    I'd say based on the bits of the problem description I *have* absorbed,
    which almost certainly isn't all of them, there's a fairly basic
    capability, not terribly often used in my experience, that might be of
    some use:

    https://docs.python.org/3/library/string.html#template-strings



    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)