Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --dump-to option to save the messages to the filesystem #107

Closed
wants to merge 1 commit into from

Conversation

nickolay
Copy link

This adds a --dump-to option, which can be:

  • either a path to an existing directory (in which N.eml files will be created)
  • or a jinja template specifying the file names to create (e.g. ./{{_mailmerge_message_num}}.eml)

The feature was requested in #103

There are no tests and I didn't check anything more complex than running pytest on Python 3.8, but once the approach is agreed on I can go through the instructions.
(Python 2 is EOL, do you still want to support it?)

@codecov-io
Copy link

codecov-io commented Oct 18, 2020

Codecov Report

Merging #107 into develop will decrease coverage by 2.10%.
The diff coverage is 61.11%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #107      +/-   ##
===========================================
- Coverage    99.03%   96.93%   -2.11%     
===========================================
  Files            6        6              
  Lines          312      326      +14     
===========================================
+ Hits           309      316       +7     
- Misses           3       10       +7     
Impacted Files Coverage Δ
mailmerge/__main__.py 94.92% <50.00%> (-4.30%) ⬇️
mailmerge/template_message.py 99.09% <83.33%> (-0.91%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 35a4b71...c1d1c46. Read the comment docs.

@awdeorio
Copy link
Owner

awdeorio commented Nov 2, 2020

This is a great sketch of a first step towards implement reliable email delivery #36. I'm going to close in favor of a more comprehensive future solution that include reliable delivery.

As per the discussion in #103, using mailmerge as a message generator only can be accomplished by mailmerge --output-format raw together with a short script. You could also use csplit, here's an example that could still use a bit of cleanup.

$ mailmerge --sample
$ mailmerge --no-limit --output-format raw | csplit - '/^>>> message.*sent*$/'
$ cat xx00
>>> message 1
TO: [email protected]
SUBJECT: Testing mailmerge
FROM: My Self <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Date: Mon, 02 Nov 2020 20:25:38 -0000

Hi, Myself,

Your number is 17.
$ cat xx01
>>> message 1 sent
>>> message 2
TO: [email protected]
SUBJECT: Testing mailmerge
FROM: My Self <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Date: Mon, 02 Nov 2020 20:25:38 -0000

Hi, Bob,

Your number is 42.
>>> message 2 sent
>>> This was a dry run.  To send messages, use the --no-dry-run option.

@awdeorio awdeorio closed this Nov 2, 2020
@nickolay
Copy link
Author

nickolay commented Nov 2, 2020

Didn't know about csplit, thanks!

I'm not sure I like the idea of gleaning the e-mails from the output intended for humans, though. Can the --output-format=raw be changed to print \0-delimited emails, without additional logging?

@awdeorio
Copy link
Owner

awdeorio commented Nov 3, 2020

Maybe a --silent option, which would suppress all the >>> lines. Then you could just do

$ mailmerge --no-limit --output-format raw | csplit - '/^TO: /' '{*}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants