There are several methods for sending mail from linux. For Example you can send email by using Exchange. To perform this you must grant relay rights to your server at first.
In this article, we will assume that the server has Relay rights(talk with system administrator) and we will send email from linux.
You need to add the name of your relay host to the conf file below.
In this conf file you can change different parameters like hostname, mydomain, inet_interfaces, but I’m just going to change the relayhost.
relayhost = [relayservername_or_ip]:relayport
After saving the change you can send mail with the help of the following command.
echo "Your message" | mail -r alert1@alert -s "Message Subject" email@example.com
After running the command, you should see the mail as follows.