Linux mail multiple recipients
To send an email to multiple recipients in Linux, you can use the -s
option with the mail
command or the sendmail
command.
Using the mail
command:
You can use the following syntax:
mail -s "Subject" [email protected],[email protected],[email protected]
Replace Subject
with the subject of the email, and [email protected]
, [email protected]
, and [email protected]
with the email addresses of the recipients.
Using the sendmail
command:
You can use the following syntax:
sendmail -t -i [email protected],[email protected],[email protected]
The -t
option tells sendmail
to read the email from standard input, and the -i
option tells it to ignore the From
header.
Using a mail client:
You can also use a mail client like mutt
or alpine
to send an email to multiple recipients. For example, with mutt
:
mutt -s "Subject" [email protected],[email protected],[email protected]
Using a script:
You can also use a script to send an email to multiple recipients. For example, you can use the following script:
#!/bin/bash
subject="Subject"
recipients="[email protected],[email protected],[email protected]"
echo "To: $recipients"
echo "Subject: $subject"
echo ""
echo "Body of the email"
| mail -s "$subject" $recipients
Make the script executable by running chmod +x script.sh
, and then run it by running ./script.sh
.
Note: Make sure to replace [email protected]
, [email protected]
, and [email protected]
with the actual email addresses of the recipients.