batch file - sending text message to email list

  • Q: I'm sending multiple mails to the list of addresses that are contained in addressees.txt. How can I send these emails one by one in such a way that recipients do not see each other (-TO field must contain only one email)?
  • A: The easiest way to solve this problem would be creating a batch file which processes addressees.txt file and sends out e-mails one by one automatically.

Since febooti Command line email version 3.0 it is possible to use -TOEACH (or -SPLIT) parameter to separate / split recipients.

The example mentioned below proceeds with each line contained in addressees.txt file and sends out an individual mail to each address.

@Echo off
rem Send email to each recipient one by one
rem using addressees.txt file


for /F %%u in (addressees.txt) DO febootimail -FROMNAME Doe -FROM sender@command-line-email.com -TO %%u -TEXT "DOS email message"

rem NOTE...
rem This batch file works with text files that contain only
rem e-mail addresses (separated with line feeds)
rem without any other textual information.
 

To send email to a list of recipients which contains more than just plain addresses, it is possible to use tokens parameter in your batch file. E.g. If addressees.txt is formatted in the way mentioned just below (or alike), pay attention that there are leading numbers before each email address. To extract email addresses token parameter has to be used - tokens=2 means that second logically separated value will be extracted and passed to command line email.

1. john@recipient.com
2. john@sender.com
   ...
9. neo@mailer.com 
FOR /F "tokens=2" %%u IN (addressees.txt) DO febootimail -CONFIRM -FROM sender@command-line-email.com -TO %%u -MSG "send individual emails to multiple recipients by processing source addressees.txt file line by line" 

To perform the same operation from command line (not using batch file) the following command must be executed. Pay attention that only one percent mark before variables is used (cf. in batch files %% should be used).

C:\>FOR /F "tokens=2" %u IN (addressees.txt) DO febootimail -FROM john@command-line-email.com -TO %u -MSG "sending individual email messages from MS-DOS prompt" 

Executing the abovementioned commands technically means that e-mails will be sent one by one (not only received individually), febooti command line utility will be executed in separate process to proceed with each mail which also allows to avoid problems connected with the issue that some SMTP mail servers accept limited recipient line length (e.g. RFC822 specifies 10000 byte header limit).

Please do not hesitate to contact our support department with any possible further questions or to solve practical issues connected with Command line email. The solution will be provided shortly by e-mail and eventually added to FAQ.