Configuring smtp settings and then sending the mail through shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Configuring smtp settings and then sending the mail through shell script
# 1  
Old 09-23-2013
Wrench Configuring smtp settings and then sending the mail through shell script

I have make an menu in which first option is to start and second is to stop the services

Code:
 echo "Please enter the appropriate choice for doing the operations"
        echo "
        1) STOP Services        
        2) START Services 
        
    case $choice in
        1)
            echo "*************Stopping Services**************"
            stopAll.sh
            ;;
        2)
            echo "*************Starting Services**************"
            startAll.sh
            ;;

now please advise I want to add the functionality of email also in it that is lets say if some one stop the services by pressing the 1 option then a mail should be launched with the subject that services are stopped and with the body also that services are stopped at that time when the option 1 is pressed ,

Now i have some specific settings of the mail server from which the mail will be send to the users as shown below..

Code:
email.smtp.host=12.120.94.54
email.smtp.port=1341

PHP Code:
Now the users id abc@gfty.com 
please advise how to customize and the add the functionality of email I want to do the smtp host and port settings within the mail and then want to send the mail, please advise. Smilie
# 2  
Old 09-26-2013
I would recommend just using the OS mailer:
Code:
echo "User $USER ran STOP at `date`" | mail -s "your subject line" abc@gfty.com

Let your OS sort out how to get the mail to the target. If you need to tweak your locally running sendmail/postfix/etc config then do that first.

Otherwise you'll have to create/install a full-blown mail client first.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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: display_remote_IP | sort | uniq | while read i do FOUND=0 for IP in `echo $ACCEPTABLEIP` do if ; then FOUND=1... (2 Replies)
Discussion started by: ldapguy
2 Replies

2. Shell Programming and Scripting

Sending mail from shell script

Hello All, I m trying to send mail from my unix script, I have used the below command mailx -s 'hi' email address < temp.txt It is not giving me any error,but I couldn't receive the mail Can you please help me. Many Thanks, Pragyan (6 Replies)
Discussion started by: prarat
6 Replies

3. Shell Programming and Scripting

shell script not sending mail

Hi, I have shell script which checks the filesystem check but does not send the mail. I might be missing something very simple.. could you please help? #!/bin/sh _servers="machine name" _out="/tmp/output.$$" _email="me@there.com" _sub="Disk Space Report $(date)" _mail=/usr/bin/mail... (5 Replies)
Discussion started by: Pandee
5 Replies

4. Shell Programming and Scripting

php code - Sending mail with external SMTP server

Here is the code: <?php //new function function loadini($path) { $fp = fopen($path, "r"); $fpcontents = fread($fp, filesize($path)); fclose($fp); return $fpcontents; } $to = "test@test.com"; $nameto = "notme"; $from = "test"; $namefrom = "Who From"; ... (0 Replies)
Discussion started by: galford
0 Replies

5. Shell Programming and Scripting

Getting error while sending mail via smtp

Hi All, I used before a simple routine code in tcl to send mail. package require smtp package require mime package require Tcl proc send_simple_message {recipient email_server subject body} { set token mime::setheader $token Subject $subject smtp::sendmessage $token \ ... (0 Replies)
Discussion started by: zivsegal
0 Replies

6. Shell Programming and Scripting

Shell script for sending automatic email to personal mail id

hi guys, I need a shell script to send mail automatically to my personal mail id like xxxx@hotmail.com but while experimenting with "mail" command I faced following problems. cat text1.txt | mail -s 'test mail' xxxx@hotmail.com command successfully executed but while checking for... (4 Replies)
Discussion started by: rrd1986
4 Replies

7. Shell Programming and Scripting

sending a mail using shell script

Please help me in writing the script for sending an attachment through email.(For example my text file name is :abc.txt and it is in directory d:/abc) (1 Reply)
Discussion started by: anitha126
1 Replies

8. UNIX for Advanced & Expert Users

Configuring Linux box with the smtp mail server

Hi all, I was trying to configure SMTP server with my linux box. I made changes to the /etc/mail/sendmail.cf whereby editing the line DAEMON_OPTIONS(`Port=<port number>,Addr=<mail server name>, Name=MTA')dnl after this ive created a new sendmail.cf file by using the command m4... (4 Replies)
Discussion started by: amit_kv1983
4 Replies

9. UNIX for Dummies Questions & Answers

sending mail via smtp

Hi Gururs, I have a process on a middelware (SAP XI) that is runnung on HP-UX. This Process is creating a flatfile. Now I want to call a script within the process that sends the created flatfile as attachment via Mail using a smpt-server. The script should have the following input parameters:... (2 Replies)
Discussion started by: elko.hasse
2 Replies
Login or Register to Ask a Question