forgot to add: the sneaky part is the smtp_out_server init.ora/spfile parameter.
Main Topics
Browse All TopicsPlease advise on how can i send email from oracle procedure. I have a requiremnt in which i need to send an alert email if count does not match. I never used email in procedure before.
Please assist.
Example-
x=select count(*) from table A;
y-select count(*) from table B;
If x=y
then
insert into c select * from table A;
else
Send alert email to team that count does not match <----- How to do this part???
Thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi slightwv,
From where, I can find sender_v email address?
----
declare
sender_v varchar2(50) := 'databaseServer@mydomain.c
recipient_v varchar2(50) := 'someuser@mydomain.com';
subj_v varchar2(100);
difference number;
begin
select count(*) into difference from tab1;
select count(*) - difference into difference from tab2;
if difference != 0 then
utl_mail.send(
sender => sender_v,
recipients => recipient_v,
subject => 'We have a problem.',
message => 'Counts are off by ' || to_char(difference)
);
end if;
end;
I was hoping you would have looked at the docs in the link I posted. It's all in there.
Not sure why but the docs also have you run:
$ORACLE_HOME/rdbms/admin/p
More on the 'sender', this is also know as spoofing emails. You can make it look like the email is sent from the president of your country. Just be aware as sdstuber mentioned, this is also who the replies go to.
>>not prvtmail.sql
pulled from the docs.
>>Can i try to run this procedure through bash script where i can use mail -x command to send mail. If yes, how can i execute this oracle procedure in bash shell script?
using mailx is a different solution entirely. What issues are you trying to solve here?
UTL_MAIL bypasses the operating system all together. If you want the OS to send the mail then you probably don't need a stored procedure at all.
Business Accounts
Answer for Membership
by: slightwvPosted on 2009-11-04 at 09:54:18ID: 25741942
What version of Oracle? If 10g or above, look up UTL_MAIL. It's pretty straight forward.
acle.com /d ocs/cd/B 12 037_01/a pp dev.101/ b1 0802/u_m ai l.htm
http://download.or