How Add Sender Email in Bash Script?
by Mo_ from LinuxQuestions.org on (#6DE59)
Hi Community,
I created a bash script that sends an email notification once a week. It's adding root@localhost as the sender. I want to add a custom email as the sender, such as noreply@example.com. However, it's not changing the sender; instead, it's sending mail to the sender. Following is a short code that I created for testing. How can I add the sender email in the bash script?
Code:#!/bin/bash
emails='receiver@example.com'
sender='noreply@example.com'
echo "This is a test email." | mail -s "Test email" $emails -r $senderThank you,
I created a bash script that sends an email notification once a week. It's adding root@localhost as the sender. I want to add a custom email as the sender, such as noreply@example.com. However, it's not changing the sender; instead, it's sending mail to the sender. Following is a short code that I created for testing. How can I add the sender email in the bash script?
Code:#!/bin/bash
emails='receiver@example.com'
sender='noreply@example.com'
echo "This is a test email." | mail -s "Test email" $emails -r $senderThank you,