| | |
Using Shell Script how to send mail automatically
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2005
Posts: 3
Reputation:
Solved Threads: 0
Hi,
You don't need to write shell script for this one. You can do it in command line itself.
echo "This is mail body" | mail -s "This is subject" mail_ID@somedomain.com
Or
cat mail_body_file.txt | mail -s "This is subject" mail_ID@somedomain.com
You don't need to write shell script for this one. You can do it in command line itself.
echo "This is mail body" | mail -s "This is subject" mail_ID@somedomain.com
Or
cat mail_body_file.txt | mail -s "This is subject" mail_ID@somedomain.com
•
•
Join Date: Apr 2008
Posts: 58
Reputation:
Solved Threads: 9
You have already been told - just use the mail command to do what you want to do, nested in the logic you want it done for.
For instance, the following will check to see if a file exists every 3 minutes. If the file exists, it will e-mail the contents of the file to mail_ID@somedomain.com and then move the file to another location (so that the same file is not sent again).
[I believe]You will need to have an e-mail server installed on the machine. Otherwise, there is a perl script out there called "sendemail.pl" that you can probably google - this script will allow you to bounce the email off a relay server - an actual SMTP server such as exchange.
... Just now realizing how old the original request is - too much typing to turn back now.
For instance, the following will check to see if a file exists every 3 minutes. If the file exists, it will e-mail the contents of the file to mail_ID@somedomain.com and then move the file to another location (so that the same file is not sent again).
Shell Scripting Syntax (Toggle Plain Text)
while [1] do if [ -f /path/to/file ] then cat /path/to/file | mail -s "This is subject" mail_ID@somedomain.com mv /path/to/file /path/to/somewhere/else fi sleep 180 done
[I believe]You will need to have an e-mail server installed on the machine. Otherwise, there is a perl script out there called "sendemail.pl" that you can probably google - this script will allow you to bounce the email off a relay server - an actual SMTP server such as exchange.
... Just now realizing how old the original request is - too much typing to turn back now.
Last edited by omrsafetyo; Nov 6th, 2008 at 7:20 pm.
![]() |
Similar Threads
- Program to send mail automatically if it satisfies some condition (JSP)
- command to telnet console using shell-script (Shell Scripting)
- how to use fastmail in shell script to send mail? (Shell Scripting)
- send mail after script finishes running (Shell Scripting)
- HElP script for send mail (Shell Scripting)
- Help "sell script to send a mail" (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: bash:redirecting stdin to at command
- Next Thread: awk percentage problem
| Thread Tools | Search this Thread |





