Sending email from terminal

Is it possible to send an email from the terminal to an email address hosted by mail in a box from the same server it self ?

I’ve created a shell script that is executed once a week via cronjob . I want to be able to get an email notification on the result of that cronjob by modifying my shell script to send an email of the outcome of that cronjob. The cronjob is done on the same server mail in a box is hosted on and the email address I want to send and receive from is also managed by mail in a box.

Can this be done ? I dont want to install additional mail utilities on the mail in a box server , can I do this from the terminal using existing mail in a box configuration ?

Yes.

Use sendmail or mail

or you can install mutt

Here are a couple of articles regarding sendmail. Neither of which I find to be overly all encompassing.

https://clients.javapipe.com/knowledgebase/132/How-to-Test-Sendmail-From-Command-Line-on-Linux.html

In the next article only focus on example 1 and 2. DO NOT follow any of the installation instructions! If you do so you will alter your MiaB. Both sendmail and mail should already be installed.

Thank you! I installed mailutils and was able to send an email from the terminal sucessfuly!

For anyone else that may find this useful I used the below command within my shell script to email me :

mail -s ‘rsync backup Successful’ -a From:Admin<sender@.abc.com> receiver@.abc.com <<< ‘mail in a box backup successfully synced to Synology NAS’

1 Like

This topic was automatically closed after 61 days. New replies are no longer allowed.