@@ -175,57 +175,65 @@ func emailsForReg(id int, dbMap dbSelector) ([]string, error) {
175175const usageIntro = `
176176Introduction:
177177
178- The notification mailer exists to send a fixed message to a list of email
179- addresses. The attributes of the message (from address, subject, and message
180- content) are provided by the command line arguments. The message content is used
181- verbatim and must be provided as a path to a plaintext file via the -body
182- argument. The list of recipient emails should be provided via the -toFile
183- argument as a path to a plaintext file containing one email per line.
178+ The notification mailer exists to send a fixed message to the contact associated
179+ with a list of registration IDs. The attributes of the message (from address,
180+ subject, and message content) are provided by the command line arguments. The
181+ message content is used verbatim and must be provided as a path to a plaintext
182+ file via the -body argument. A list of registration IDs should be provided via
183+ the -toFile argument as a path to a plaintext file containing JSON of the form:
184+
185+ [
186+ { "id": 1 },
187+ ...
188+ { "id": n }
189+ ]
184190
185191To help the operator gain confidence in the mailing run before committing fully
186192three safety features are supported: dry runs, checkpointing and a sleep
187193interval.
188194
189- The -dryRun flag will use a mock mailer that prints message content to stdout
190- instead of performing an SMTP transaction with a real mailserver. This can be
191- used when the initial parameters are being tweaked to ensure no real emails are
192- sent.
195+ The -dryRun=true flag will use a mock mailer that prints message content to
196+ stdout instead of performing an SMTP transaction with a real mailserver. This
197+ can be used when the initial parameters are being tweaked to ensure no real
198+ emails are sent. Using -dryRun=false will send real email .
193199
194200Checkpointing is supported via the -start and -end arguments. The -start flag
195- specifies which line of the -toFile to start processing at. Similarly, the -end
196- flag specifies which line of the -toFile to end processing at. In combination
197- these can be used to process only a fixed number of recipients at a time, and
198- to resume mailing after early termination.
201+ specifies which registration ID of the -toFile to start processing at.
202+ Similarly, the -end flag specifies which registration ID of the -toFile to end
203+ processing at. In combination these can be used to process only a fixed number
204+ of recipients at a time, and to resume mailing after early termination.
199205
200206During mailing the -sleep argument is used to space out individual messages.
201207This can be used to ensure that the mailing happens at a steady pace with ample
202208opportunity for the operator to terminate early in the event of error. The
203209-sleep flag honours durations with a unit suffix (e.g. 1m for 1 minute, 10s for
204- 10 seconds, etc).
210+ 10 seconds, etc). Using -sleep=0 will disable the sleep and send at full speed.
205211
206212Examples:
207213 Send an email with subject "Hello!" from the email "hello@goodbye.com" with
208- the contents read from "test_msg_body.txt" to every email listed in
209- "test_msg_recipients.txt", sleeping 10 seconds between each message:
214+ the contents read from "test_msg_body.txt" to every email associated with the
215+ registration IDs listed in "test_reg_recipients.json", sleeping 10 seconds
216+ between each message:
210217
211- notify-mailer -config test/config/notify-mailer.json
212- -body cmd/notify-mailer/testdata/test_msg_body.txt -from hello@goodbye.com
213- -toFile cmd/notify-mailer/testdata/test_msg_recipients.txt -subject "Hello!"
214- -sleep 10s
218+ notify-mailer -config test/config/notify-mailer.json -body
219+ cmd/notify-mailer/testdata/test_msg_body.txt -from hello@goodbye.com
220+ -toFile cmd/notify-mailer/testdata/test_msg_recipients.json -subject "Hello!"
221+ -sleep 10s -dryRun=false
215222
216- Do the same, but only to the first 100 recipients :
223+ Do the same, but only to the first 100 recipient IDs :
217224
218- notify-mailer -config test/config/notify-mailer.json
219- -body cmd/notify-mailer/testdata/test_msg_body.txt -from hello@goodbye.com
220- -toFile cmd/notify-mailer/testdata/test_msg_recipients.txt -subject "Hello!"
221- -sleep 10s -end 100
225+ notify-mailer -config test/config/notify-mailer.json
226+ -body cmd/notify-mailer/testdata/test_msg_body.txt -from hello@goodbye.com
227+ -toFile cmd/notify-mailer/testdata/test_msg_recipients.json -subject "Hello!"
228+ -sleep 10s -end 100 -dryRun=false
229+
230+ Send the message, but start at the 200th ID of the recipients file, ending after
231+ 100 registration IDs, and as a dry-run:
222232
223- Send the message, but start at line 200 of the recipients file, ending after
224- 100 recipients, and as a dry-run:
225233 notify-mailer -config test/config/notify-mailer.json
226234 -body cmd/notify-mailer/testdata/test_msg_body.txt -from hello@goodbye.com
227- -toFile cmd/notify-mailer/testdata/test_msg_recipients.txt -subject "Hello!"
228- -sleep 10s -start 200 -end 300 -dryRun
235+ -toFile cmd/notify-mailer/testdata/test_msg_recipients.json -subject "Hello!"
236+ -sleep 10s -start 200 -end 300 -dryRun=true
229237
230238Required arguments:
231239- body
@@ -237,7 +245,7 @@ Required arguments:
237245func main () {
238246 from := flag .String ("from" , "" , "From header for emails. Must be a bare email address." )
239247 subject := flag .String ("subject" , "" , "Subject of emails" )
240- toFile := flag .String ("toFile" , "" , "File containing a list of email addresses to send to, one per file ." )
248+ toFile := flag .String ("toFile" , "" , "File containing a JSON array of registration IDs to send to." )
241249 bodyFile := flag .String ("body" , "" , "File containing the email body in plain text format." )
242250 dryRun := flag .Bool ("dryRun" , true , "Whether to do a dry run." )
243251 sleep := flag .Duration ("sleep" , 60 * time .Second , "How long to sleep between emails." )
0 commit comments