Skip to content

Send the same email message to each recipient in a list

David-Apps edited this page Feb 26, 2022 · 12 revisions

This simple function sends the same message separately to each recipient whose email address appears in a list. The function expects 2 arguments:

  1. The number of the buffer containing the message that you want to send to each recipient. This message should include the "Subject" field.
  2. The number of the buffer containing the address list. Each line of the buffer contains an email address or an alias from your address book. The function deletes the lines of this buffer as it processes them. This makes it easier to continue processing the list after an error has occurred.

Example

Suppose that:

  1. Buffer 1 contains the message:

    Subject: News update Not much has happened, but they say that no news is good news. Perhaps the next update will be more interesting.

  2. Buffer 2 contains the address list:

    [email protected] [email protected] [email protected]

Then, we can send the message to each recipient in the list with:

<sendlist 1 2

Function

#Send a message separately to each email address in a list.
#usage: <sendlist <message buffer> <address list buffer>
#This function deletes the lines in the address list buffer as it processes them.
function+sendlist {
db0
e~2
if(?) {
#Already in the address list buffer.
}
1w~1@0
while(*) {
1d
e~1
s/^/to: /f
#Change the next line to send from a specific mail account.
sm
#Uncomment and edit the next line if you want to wait between sending messages, perhaps because your mail provider limits the number of messages that you can send during a period.
#!sleep 60
d
e~2
#Remove the next line if you do not want this progress indicator.
=
1w~1@0
}
}