Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Apr 2019 23:39:59 +0200
From:      Miroslav Lachman <000.fbsd@quip.cz>
To:        Software Info <softwareinfojam@gmail.com>, "freebsd-stable@freebsd.org" <freebsd-stable@freebsd.org>
Subject:   Re: Mailx Question
Message-ID:  <0d44d441-3120-c140-40da-7a32baff0cae@quip.cz>
In-Reply-To: <5cad0a1f.1c69fb81.c5304.4f33@mx.google.com>
References:  <5cad0a1f.1c69fb81.c5304.4f33@mx.google.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Software Info wrote on 2019/04/09 23:09:
> Hi All
> Since mailx is built into FreeBSD I decided to try asking this question here. I have a text file with about 30 email addresses. The file will change every day. I want an easy commandline way to read the file and blind copy send an email to the addresses in the file. So far, I have this working with just a plain send using the command below.
> mailx -s "Test Emails" -b `cat mylist.txt` < body.txt -r "No-Reply<no-reply@email.com>"
> 
> Of course, when I use a plain send, everybody sees everybody’s email address so I would love to be able to do a blind copy send. Would anyone be able to assist me with this?

It may depend on your MTA (Sendmail, Postfix, Exim etc.)

"You must specify direct recipients with -s, -c, or -b."

   -b bcc-addr
        Send blind carbon copies to bcc-addr list of users.  The bcc-addr
        argument should be a comma-separated list of names.

You should replace newlines with comma:

cat mylist.txt | tr "\n" ","

Maybe something like this will work for you:

mail -s "Test E-mails" -b `cat mylist.txt | tr "\n" ","` 
my-generic@example.com < body.txt

Miroslav Lachman



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0d44d441-3120-c140-40da-7a32baff0cae>