LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-23-2009, 10:21 AM   #1
adhar
LQ Newbie
 
Registered: Sep 2009
Posts: 11

Rep: Reputation: 0
Smile Need to send email from linux (RHEL 5.3) command promt


Dear All,

I am very new to linux environment. I need a solution where I can send email from my linux command prompt. I have a linux server where Oracle is installed and I have a seperate SMTP server for mailing purpose for my office. Now based on some activity in the oracle I need to send email from this server automatically to the respective email id's in the company. As I told earlier I have a SMTP server, I only need to send mail from the oracle installed linux server to the individuals. I have installed RHEL 5.3 where oracle is running.

One senario is when oracle writes a file say a alert file or trace file in the path say /oracle/admin/udump/trace directory a email will be send to our dba at dba@xxx.ae Mean to say when a OS file is generated or updated in the above linux path a mail should be fired from linux command prompt

PLZ HELP!!!

Regards
Ayon

Last edited by adhar; 09-24-2009 at 08:39 AM. Reason: Sorry for flagging URGENT
 
Old 09-23-2009, 10:40 AM   #2
ak@shdubey
LQ Newbie
 
Registered: Sep 2009
Location: India
Distribution: Redhat/Oracle Ent/CentOS
Posts: 28
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by adhar View Post
Dear All,

I am very new to linux environment. I need a solution where I can send email from my linux command prompt. I have a linux server where Oracle is installed and I have a seperate SMTP server for mailing purpose for my office. Now based on some activity in the oracle I need to send email from this server automatically to the respective email id's in the company. As I told earlier I have a SMTP server, I only need to send mail from the oracle installed linux server to the individuals. I have installed RHEL 5.3 where oracle is running.

One senario is when oracle writes a file say a alert file or trace file in the path say /oracle/admin/udump/trace directory a email will be send to our dba at dba@xxx.ae Mean to say when a OS file is generated or updated in the above linux path a mail should be fired from linux command prompt

PLZ HELP URGENTLY!!!

Regards
Ayon
Please don't create multiple threads to same question,

i have replied to this thread of yours - http://www.linuxquestions.org/questi...-promt-757273/
 
Old 09-23-2009, 11:23 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by adhar View Post
Dear All,

I am very new to linux environment. I need a solution where I can send email from my linux command prompt. I have a linux server where Oracle is installed and I have a seperate SMTP server for mailing purpose for my office. Now based on some activity in the oracle I need to send email from this server automatically to the respective email id's in the company. As I told earlier I have a SMTP server, I only need to send mail from the oracle installed linux server to the individuals. I have installed RHEL 5.3 where oracle is running.

One senario is when oracle writes a file say a alert file or trace file in the path say /oracle/admin/udump/trace directory a email will be send to our dba at dba@xxx.ae Mean to say when a OS file is generated or updated in the above linux path a mail should be fired from linux command prompt

PLZ HELP URGENTLY!!!

Regards
Ayon
Please spell out your words, and don't flag your posts as urgent. We volunteer our time to help folks out, so telling us to hurry isn't very nice. If you want 24/7 **URGENT** help, pay for support from someone, and they'll be there for you.

Read the man pages for the sendmail and mailx commands. They send mail from the command line, and are widely used. However, you will need to configure some sort of mail transport agent (like sendmail or postfix), on your system, so it knows how to route the mail outwards. All that depends on your environment. If you already have an internal mail host, find out if it supports incoming relay connections. If it does, configure postfix to use it as a relay host (lots of info on Google for this), then use mailx to send messages.
 
Old 09-23-2009, 08:47 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Sounds like you need to write a custom prog eg in Perl to monitor whatever your specific conditions are and send the email.
Apparently you've got an MTA (SMTP Transport) running; I'd guess sendmail.
You can test it from the cmd line like

echo "Test email body" | mailx -r you@xxx.com -s "Test Email"

to check you've got email connectivity.

If you want a perl sub that does the equiv, post a reply here.
 
Old 09-23-2009, 08:56 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Sorry---did not see that the other one was closed

Last edited by pixellany; 09-23-2009 at 08:58 PM.
 
Old 09-24-2009, 12:30 AM   #7
adhar
LQ Newbie
 
Registered: Sep 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Dear All,

Very Very sorry for posting 2 threads. I was little confused whether I was posting to correct forum. And I apologies for flagging as "urgent". I am very new to linux and forums.... sorry once again.

Hi ak@shdubey
When I run the commands as told by you following are the outputs:
[root@erpnonprod /]# ps -aef |grep mail
root 3591 1 0 Sep15 ? 00:00:00 sendmail: accepting connections
smmsp 3600 1 0 Sep15 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 24615 24578 0 09:11 pts/1 00:00:00 grep mail
[root@erpnonprod /]# rpm -qa |grep mail
mailcap-2.1.23-1.fc6
procmail-3.22-17.1
mailx-8.1.1-44.2.2
sendmail-8.13.8-2.el5
fetchmail-6.3.6-1.1.el5
sendmail-cf-8.13.8-2.el5
[root@erpnonprod /]# rpm -qa |grep mail adhar@xxx.ae
grep: adhar@xxx.ae: No such file or directory
[root@erpnonprod /]#

Hi chrism01,
How do I know sendmail is working or not. If no then how to configure it.
When I run echo "Test email body" | mailx -r adhar@xxx.ae -s "Test Email" command following are the output
[root@erpnonprod /]# echo "Test email body" | mailx -r adhar@xxx.com -s "Test Email"
mailx: invalid option -- r
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
[root@erpnonprod /]#
then I gave the following command...but no mail was send to my outlook express mailbox....
root@erpnonprod /]# echo "Test email body" | mailx to adhar@xxx.ae -s "Test Email"
[root@erpnonprod /]#

Thanks all for your kind help..
Regards
Ayon

Last edited by adhar; 09-24-2009 at 12:40 AM.
 
Old 09-24-2009, 03:49 AM   #8
DrLove73
Senior Member
 
Registered: Sep 2009
Location: Srbobran, Serbia
Distribution: CentOS 5.5 i386 & x86_64
Posts: 1,118
Blog Entries: 1

Rep: Reputation: 129Reputation: 129
I think you need to configure outgoing (SMTP) server for sendmail, so mail can leave your server. This should help:

Quote:
How To Configure Linux Sendmail Clients

All Linux mail clients in your home or company need to know which server is the mail server. This is configured in the /etc/mail/sendmail.mc file by setting the SMART_HOST statement to include the mail server. In the example below, the mail server has been set to mail.my-site.com, the mail server for the my-site.com domain.

define(`SMART_HOST',`mail.my-site.com')

If you don't have a mail server on your network, you can either create one, or use the one offered by your ISP.

Once this is done, you need to process the sendmail.mc file and restart sendmail. To do this, run the restarting script we from earlier in the chapter.

If the sendmail server is a Linux server, then the /etc/hosts file will also have to be correctly configured too.

From http://www.linuxhomenetworking.com/w...x_Mail_Servers

Better option for setting up linux servers for me is Webmin package: http://prdownloads.sourceforge.net/w...0-1.noarch.rpm . It has nice web interface on https://<yourIPorDomainName>:10000 (standalone web server, no Apache necessary) and you can setup (almost) ANYTHING on your server. Very powerfull tool to have and to use.

It also has THIRD PARTY (by author of Webmin) Oracle module made in 2006. I would not use it to change any settings on production server, but viewing made changes and current setup of your Oracle server would come handy.
 
Old 09-24-2009, 08:36 AM   #9
adhar
LQ Newbie
 
Registered: Sep 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Smile

Hi DrLove73,

Resolved!!

Thanks
 
Old 10-21-2009, 10:13 AM   #10
misconfiguration
Member
 
Registered: Apr 2007
Location: Indianapolis, Indiana
Distribution: RHEL, Fedora, AIX, HP-UX, FreeBSD, Slackware
Posts: 62

Rep: Reputation: 19
In order to send the contents of somefile in an email VIA command line, first check to see if sendmail is running.

Code:
service sendmail restart
Now sent your email:

Code:
cat <path to some file> | mailx -s "my subject" someone@example.com
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Send email from command line markotitel Linux - Newbie 4 10-26-2009 08:41 AM
Need to send email from command promt adhar Red Hat 3 09-23-2009 10:57 AM
How to send an email-RHEL AS3 whattodo Linux - Server 5 02-26-2008 02:17 PM
How do I send email from command prompt? munna_dude Programming 4 04-10-2007 09:16 AM
send email from command line djionel82 Programming 6 11-29-2005 12:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration