Using sendmail from bash script for multiple recipients

Try doing this:

recipients="user1@mail.example,user2@mail.example,user3@mail.example"

And another approach, using shell here-doc:

/usr/sbin/sendmail "$recipients" <<EOF
subject:$subject
from:$from

Example Message
EOF

Be sure to separate the headers from the body with a blank line as per RFC 822.

Leave a Comment