Using Shell Script how to send mail automatically

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2005
Posts: 2
Reputation: sanju456 is an unknown quantity at this point 
Solved Threads: 0
sanju456 sanju456 is offline Offline
Newbie Poster

Using Shell Script how to send mail automatically

 
0
  #1
Jan 31st, 2005
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)
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 3
Reputation: Durai is an unknown quantity at this point 
Solved Threads: 0
Durai Durai is offline Offline
Newbie Poster

Re: Using Shell Script how to send mail automatically

 
0
  #2
Feb 3rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1
Reputation: shankha_achar is an unknown quantity at this point 
Solved Threads: 0
shankha_achar shankha_achar is offline Offline
Newbie Poster

Re: Using Shell Script how to send mail automatically

 
0
  #3
Nov 6th, 2008
how to send autometic mail usins Linux shell script
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Re: Using Shell Script how to send mail automatically

 
0
  #4
Nov 6th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC