LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Need to send email from linux (RHEL 5.3) command promt (https://www.linuxquestions.org/questions/linux-general-1/need-to-send-email-from-linux-rhel-5-3-command-promt-757278/)

adhar 09-23-2009 10:21 AM

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

ak@shdubey 09-23-2009 10:40 AM

Quote:

Originally Posted by adhar (Post 3694311)
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/

TB0ne 09-23-2009 11:23 AM

Quote:

Originally Posted by adhar (Post 3694311)
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.

DrLove73 09-23-2009 07:11 PM

Here ar few usefull links:

http://linux.die.net/man/1/mailx
http://opendba.blogspot.com/2004/11/...via-mailx.html
http://forums11.itrc.hp.com/service/...hreadId=124727
http://forums11.itrc.hp.com/service/...hreadId=837380
http://dbaspot.com/forums/oracle-ser...t-working.html
http://allappsdba.blogspot.com/2008/...unix-with.html

chrism01 09-23-2009 08:47 PM

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.

pixellany 09-23-2009 08:56 PM

Sorry---did not see that the other one was closed

adhar 09-24-2009 12:30 AM

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

DrLove73 09-24-2009 03:49 AM

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.

adhar 09-24-2009 08:36 AM

Hi DrLove73,

Resolved!!

Thanks

misconfiguration 10-21-2009 10:13 AM

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


All times are GMT -5. The time now is 11:18 AM.