LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to send a mail using shell script (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-send-a-mail-using-shell-script-4175439258/)

gajananh999 11-29-2012 01:41 AM

How to send a mail using shell script
 
Dear Everyone,

I new to linux shell programming please can anyone tell me how to send a mail using shell script.

I have done it using php and now i m able to send a mail using PHP (mail) function from my linux machine.

But is there any possibility to send a mail using shell script?

SqdnGuns 11-29-2012 01:45 AM

Quote:

Originally Posted by gajananh999 (Post 4839299)
Dear Everyone,

I new to linux shell programming please can anyone tell me how to send a mail using shell script.

I have done it using php and now i m able to send a mail using PHP (mail) function from my linux machine.

But is there any possibility to send a mail using shell script?

Maybe this will point you in the right direction.

http://theos.in/shell-scripting/send-mail-bash-script/

shivaa 11-29-2012 01:55 AM

Yes you can. But first check whether any mail service is running in your Unix machine or not. For instance,
Code:

ps -ef | egrep "smtp|postfix"
If it is running, then you can use:
Code:

mailx -s "subject" user@example.com < /path/to/file
Where /path/to/file is file containing message i.e. body of the mail.


All times are GMT -5. The time now is 03:39 AM.