media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

How To Send Mail To Multiple Addresses Using (mailx)

In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail.

I assume you already have mailx command, if you don't already have it installed, use sudo apt install mailutils, once installed, we can get started using mailx.

To send mail to multiple address, you do the following:

echo "My message" | mail -s "My Mail Subject"

or by taking the message from a file (CD into the file directory, and use the following command):

mail -s "My Mail Subject" < textfile.txt

Add Attachment to the Mail

Attachment can be added with the -aswitch:

echo "My Message Body" | mail -s "My Mail Subject" -a /path/to/file

You can also specify a from name address, use the -r option and wrap the name in "<>", e.g:

echo "My Message Body" | mail -s "My Mail Subject" -r "<>"-a /path/to/file

Let's spice this up by using alias,add the list of users you want to send the mail to using:

alias mailadresses=""

Then send the mail using:

echo "My message" | mail -s "My Mail Subject" mailaddresses