|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Sending Mail via shell script
I am in need of a script that will send out emails while going through a NAT. What I have that works is as follows: Code:
display_remote_IP | sort | uniq | while read i
do
FOUND=0
for IP in `echo $ACCEPTABLEIP`
do
if [ "$i" == "$IP" ]; then
FOUND=1
continue
fi
done
if [ $FOUND -eq 0 ]; then
echo "IP address $i NOT in acceptable IP list to access server ...... sending email"
echo "IP Address $i NOT in acceptable IP list to access server, please investigate" | mail -s "Unauthorized Connection To My_Server Alert" someone@mail.com
fi
doneNow I have to run this in an environment where the mail server is not in DNS. I therefore have to go through a NAT, 100.100.100.100 How do I add that to my script so that it goes through the IP to send the email?
Last edited by jim mcnamara; 06-12-2012 at 04:24 PM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Quote:
Long version: it is simply not the task of a script to "know how to deliver mails". This should be the knowledge of the mailing daemon and be configured there. "mail" (which you use in your script) is a client program which acts as a frontend to this delivery system: it takes a mail message with all relevant information (addressee, content, subject line, etc.) and passes this to a daemon (sendmail, whatever), which should deliver this to an MTA (mail transfer agent) or to the addressees systems mail service directly. In any case your script should not be concerned with how mail gets there. To use an analogy: if you want to use any other IP service (say, FTP) in your script, it shouldn't be concerned in dealing with IP routing or something such either - this would be the job of routers, so let them do it. Bottom line: configure your "sendmail" or whatever you use to send mails properly and leave your perfectly written script alone. I hope this helps. bakunin |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks bakunin for the response. That makes a lot of sense now. I got the server guys to check that out and you were right, sendmail was not configured correctly in that environment.
Appreciate your help!! |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sending mail from shell script | prarat | Shell Programming and Scripting | 6 | 06-04-2012 06:56 AM |
| shell script not sending mail | Pandee | Shell Programming and Scripting | 5 | 04-26-2012 03:01 AM |
| Shell script for creating log file and sending mail? | san_dy123 | Shell Programming and Scripting | 4 | 02-29-2012 05:01 AM |
| Shell script for sending automatic email to personal mail id | rrd1986 | Shell Programming and Scripting | 4 | 01-19-2010 12:53 PM |
| sending a mail using shell script | anitha126 | Shell Programming and Scripting | 1 | 11-27-2008 06:31 AM |
|
|