944,017 Members | Top Members by Rank

Ad:
Jan 31st, 2005
0

Using Shell Script how to send mail automatically

Expand Post »
Hi all,
Problem: Send mail is configured in my system and now i want to write a shell script using which i can send mail to my rediffmail account.

Its little urgent & i will be very thankful if someone send me the code.
regards,
Sanjeev Kumar(sanju456@rediffmail.com)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanju456 is offline Offline
2 posts
since Jan 2005
Feb 3rd, 2005
0

Re: Using Shell Script how to send mail automatically

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Durai is offline Offline
3 posts
since Feb 2005
Nov 6th, 2008
0

Re: Using Shell Script how to send mail automatically

how to send autometic mail usins Linux shell script
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shankha_achar is offline Offline
1 posts
since Apr 2008
Nov 6th, 2008
0

Re: Using Shell Script how to send mail automatically

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).
Shell Scripting Syntax (Toggle Plain Text)
  1. while [1]
  2. do
  3. if [ -f /path/to/file ]
  4. then
  5. cat /path/to/file | mail -s "This is subject" mail_ID@somedomain.com
  6. mv /path/to/file /path/to/somewhere/else
  7. fi
  8. sleep 180
  9. 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.
Reputation Points: 13
Solved Threads: 9
Junior Poster in Training
omrsafetyo is offline Offline
58 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: bash:redirecting stdin to at command
Next Thread in Shell Scripting Forum Timeline: awk percentage problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC