Urgent - Mail from Oracle
Dear friends,
I want 2 send mail from Oracle PL/SQL . I have used the
following code to send mail.
create or replace PROCEDURE send_mail_1 (sender IN VARCHAR2,
recipient IN VARCHAR2,
message IN VARCHAR2)
IS
mailhost VARCHAR2(30) := 'mailhost.mydomain.com';
smtp_error EXCEPTION;
mail_conn utl_tcp.connection;
PROCEDURE smtp_command(command IN VARCHAR2,
ok IN VARCHAR2 DEFAULT '250')
IS
response varchar2(3);
x number;
BEGIN
x:= utl_tcp.write_line(mail_conn, command);
response := substr(utl_tcp.get_line(mail_conn), 1, 3);
IF (response <> ok) THEN
RAISE smtp_error;
END IF;
END;
BEGIN
mail_conn := utl_tcp.open_connection(mailhost, 25);
smtp_command('HELO ' || mailhost);
smtp_command('MAIL FROM: ' || sender);
smtp_command('RCPT TO: ' || recipient);
smtp_command('DATA', '354');
smtp_command(message);
smtp_command('QUIT', '221');
utl_tcp.close_connection(mail_conn);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
END;
I am able to successfuly create the procedure. But while
executing the procedure I got the following error "ORA-29540:
class oracle/plsql/net/TCPConnection does not exist".
I have used the following format while I tried executing the
procedure
execute send_mail_1
('[email protected]','[email protected]','Test')
Are the above parameters are correct?. Further should I need to
change 'mailhost.mydomain.com' string value?- If yes what value
should be given there?
mailhost VARCHAR2(30) := 'mailhost.mydomain.com';
Kindly help me in this regards.
Thanks in advance
Narayanan
Something like:
Create or Replace Procedure Send_Reminder IS
CURSOR cur_reminders_needed IS
SELECT *
FROM mytable
where trunc(reminder_date) = trunc(sysdate)
FOR UPDATE OF reminder_date;
BEGIN
For rec in cur_reminders_needed LOOP
my_mail_pkg.send_emal(rec.stuff_from_my_table);
UPDATE mytable set reminder_date = reminder_date+rec.reminder_increment
WHERE CURRENT OF cur_reminders_needed;
END LOOP;
COMMIT;
END;Then use dbms_job.submit to create a job that runs send_reminders every day.
Then take a nap, Oracle will do everything else.
Similar Messages
-
How a send a mail from Oracle ----- urgent
Hi,
I am working in oracle9i and linux 2.4. i need to a send mail from oracle .Please send the procedure to me in a detail manner.
I am having one procedure .plz check and change if possible...
declare
l_maicon utl_smtp.connection;
begin
l_maicon :=utl_smtp.open_connection('mail.com');
utl_smtp.helo(l_maicon,'mail.com');
utl_smtp.mail(l_maicon,'[email protected]');
utl_smtp.rcpt(l_maicon,'[email protected]');
utl_smtp.data(l_maicon,'From: [email protected]' || utl_tcp.crlf||
'To: [email protected]' || utl_tcp.crlf ||
'Subject: database e-mail option' || utl_tcp.crlf ||
'You have received this mail from database!');
utl_smtp.quit(l_maicon);
end;
Please explain me in detail
Gobi....If I do a Google search on the terms "Oracle mail", this askTom thread is the second hit
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:255615160805
Did you already find this thread? If so, did it not answer your question sufficiently?
Additionally, it would be quite helpful if you would post the results of running the code you posted. You've given no indication whether there is an error, what error might be generated, whether you're not seeing the expected behavior, whether the code crashes your system, etc. That leaves us to guess about what problems you might have between syntax errors, permission problems, configuration problems on the database, configuration problems on the SMTP server, operating system problems, network problems (the list goes on).
Justin -
Sending a mail from oracle database
Hi,
I have a requirement to send a mail from oracle database.I use UTL_TCP package for this.Although my procedure is executed successfully,i dont get the mails in my inbox.Please help me to figure out a solution.
Thanks in advance....Hi, you must use UTL_SMTP package for send emails, it has more performance and features for debug. You must look the next code, this is a example for send emails.
DECLARE
c UTL_SMTP.CONNECTION;
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
END;
BEGIN
c := UTL_SMTP.OPEN_CONNECTION('smtp-server.acme.com');
UTL_SMTP.HELO(c, 'foo.com');
UTL_SMTP.MAIL(c, '[email protected]');
UTL_SMTP.RCPT(c, '[email protected]');
UTL_SMTP.OPEN_DATA(c);
send_header('From', '"Sender" <[email protected]>');
send_header('To', '"Recipient" <[email protected]>');
send_header('Subject', 'Hello');
UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF || 'Hello, world!');
UTL_SMTP.CLOSE_DATA(c);
UTL_SMTP.QUIT(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
BEGIN
UTL_SMTP.QUIT(c);
EXCEPTION
WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
NULL; -- When the SMTP server is down or unavailable, we don't have
-- a connection to the server. The QUIT call will raise an
-- exception that we can ignore.
END;
raise_application_error(-20000,
'Failed to send mail due to the following error: ' || sqlerrm);
END;
Also review the next link for get more information about the UTL_SMTP packege.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_smtp.htm#sthref15587
Regards. -
Send mail from oracle database 10g
Hi ,
I need to send a test mail from oracle database 10g to my gmail account through a stored procedure .
I will pass the list of recipents , subject and text of the mail through parameters .
Can anyone give me the code of the storerd procedure please ,
Thank you .hi, for example
DECLARE
mail_conn UTL_SMTP.connection;
smtp_relay VARCHAR2(32) := '172.16.x.x';
recipient_address VARCHAR2(64) := '[email protected]';
sender_address VARCHAR2(64) := '[email protected]';
mail_port NUMBER := 25;
msg VARCHAR2(200);
BEGIN
mail_conn := UTL_SMTP.open_connection(smtp_relay,mail_port);
UTL_SMTP.HELO(mail_conn, smtp_relay);
UTL_SMTP.MAIL(mail_conn, sender_address);
UTL_SMTP.RCPT(mail_conn, recipient_address);
UTL_SMTP.DATA(mail_conn, 'Payment request iniated');
UTL_SMTP.QUIT(mail_conn);
end; -
Sending mail from oracle procedure
Hi Experts,
I want to send mail from oracle Procedure. Anybody please help me out.
Thanks.BEGIN
UTL_MAIL.send(sender => '[email protected]',
recipients => '[email protected],[email protected]',
cc => '[email protected]',
bcc => '[email protected]',
subject => 'UTL_MAIL Test',
message => 'If you get this message it worked!');END; -
Mails from Oracle Forum is flooding my mail box
Oracle Forum updation mails are flooding my mail box. kindly let me know how can I stop the mails from Oracle Forum from flooding my inbox.
RegardsChange your e-mail address. Like you I'm not interested in forum notifications via e-mail - I get a deluge of mails that are pretty meaningless.
So I changed my notification to weekly (to decrease the number of SMTP bounces on the OTN side) and added "+-no-spam-thanks+" to my e-mail address supplied to OTN for notification.
Works fine.. never had OTN complaining about it and have received private mails from OTN in the past (meaning that they did see and use this e-mail addy with suffix without problems). -
I have used Oracle 9i server (9.2.0.1 version) on Windows XP machine(with SP2).I want to send Email from PL/SQL procedure.
My Question is what sort of configuration needed to perform this activity?
I have installed IIS (Internet Information Service)
in my machine, then configure my SMTP mail server
with a valid email id and password given TCP port 465.
Later I came to know that to send Email from PL/SQL I have to install Oracle JServer Code. Follow three steps. the steps are
1. Execute the script as sys "$ORACLE_HOME\javavm\install\initjvm.sql"
2. Execute the loadjava classfile as
$ORACLE_HOME\plsql\jlib>loadjava -f -v -r -u sys/**** plsql.jar
3. Execute the script as sys "$ORACLE_HOME\rdbms\admin\initplsj.sql"
I sucessfully executed the first step, but for the second step iam not able to locate the plsql.jar file in the specified path.
So Please tell me if there is any other method to perform this task
My code is as follows.
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_to varchar2,
msg_subject varchar2,
msg_text varchar2
IS
c utl_smtp.connection;
rc integer;
msg_from varchar2(50) := '[email protected]';
mailhost VARCHAR2(30) := 'mail.google.com';
BEGIN
c := utl_smtp.open_connection(mailhost, 465);
utl_smtp.helo(c, mailhost);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);
dbms_output.put_line(' Start Sending data');
utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || msg_text);
dbms_output.put_line(' Finish Sending data');
utl_smtp.quit(c);
EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;
Procedure Created.
SQL> execute prc_send_mail('[email protected]','[email protected]','Good Morning.');
BEGIN prc_send_mail('[email protected]','[email protected]','Good Morning.'); END;
ERROR at line 1:
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at "SYS.UTL_SMTP", line 17
ORA-06512: at "SYS.UTL_SMTP", line 96
ORA-06512: at "SYS.UTL_SMTP", line 374
ORA-06512: at "SCOTT.PRC_SEND_MAIL", line 19
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at line 1.
Please tell me how to solve this problem.
Thank You.1) Why did you install an SMTP server locally and then tell your code to try to use the server mail.google.com?
2) The error you're getting is from mail.google.com indicating that Google isn't running an open SMTP server there. I would be very surprised if Google were running a publicly available SMTP server anywhere since that would be an invitation for spammers.
Justin -
Send e-mail from Oracle 9i (9.2.0.1)
Hi,
Iam using oracle 9iR2(9.2.0.1) on Widows XP Platform. I want to send mail thru oracle 9i(9.2.0.1) database.
for that i got a procedure from net. Also they asked to follow three steps. the steps are
1. Execute the script as sys "D:\Oracle\Ora92\javavm\install\initjvm.sql"
2. Execute the loadjava classfile as
D:\Oracle\Ora92\plsql\jlib>loadjava -f -v -r -u sys/**** plsql.jar
3. Execute the script as sys "$ORACLE_HOME\rdbms\admin\initplsj.sql"
I sucessfully executed the first step, but for the second step i am not able to locate the plsql.jar file in the specified path.
So Please tell me if there is any other method to perform this task
Regards
Prasanta Pramanik.Is there some reason not to use the built-in UTL_SMTP package?
http://www.psoug.org/reference/utl_smtp.html
It has been available since 8.1.7. -
How to send mails from Oracle database
Hi All,
I want to send a mail from my oracle database once my store
procedure runs successfully or fails.
How can i do this.
what are the preliminary modules of Oracle which need to be
active for me to do so.
If any once can also mention about any links that give
information about the same it will be very helpful for me.
Thanks and Regards
Srinivas CheboluCREATE OR REPLACE PROCEDURE SEND_MAIL_TCP(
msg_from varchar2 := '[email protected]',
msg_to varchar2,
msg_subject varchar2 := 'E-Mail message from your database',
msg_text varchar2 := '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c := utl_tcp.open_connection('1.17.0.218', 25); -- open the SMTP
port 25 on local machine
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'HELO localhost');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
rc := utl_tcp.write_line(c, '');
rc := utl_tcp.write_line(c, msg_text);
rc := utl_tcp.write_line(c, '.'); -- End of message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'QUIT');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
utl_tcp.close_connection(c); -- Close the connection
EXCEPTION
when others then
raise_application_error(-20000,'Unable to send e-mail message
from pl/sql');
END;
show errors
exec send_mail(msg_to =>'[email protected]');
exec send_mail(msg_to
=>[email protected]',msg_text=>'Look Yaar, I can send
mail from plsql'); -
Sending Mail from Oracle forms or reports
Hi
I have to send mail from forms or reports . Is there any way or builtin to do this.
If anybody have experience in this please give the
detailed example on this.
Regards
ArunLook at http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt
It creates a package in the database for sending mail.
If you want to send mail from the local machine using Outlook, you'll have to use OLE, but it's not something I've tried. -
URGENT: Upgrade from Oracle 8.0.4 to Oracle 8.1.7
How do I upgrade Oracle 8.0.4 to Oracle 8.1.7?
Please Help me!!! I have to do this task and I don't know how to start.
ThanksHi,
Get the Migration document from oracle for 8.1.7.
Hope that helps.
Thanks,
Lanke -
how can i send e-mail from within the form and without opening any e-mail program
just one click on a button in the form the mail will be sent
i'm working on nt osI use a program called BLAT which is a command line utility to send SMTP messages.
( Use the HOST built-in ).
I tried using MAPI products but they did not work well on the web.
null -
How send mail from Oracle stored procedure?
Hi,
I need send mail using Oracle stored procedure. Can anybody helpme with any recomendation about that, sample code or so?.
[email protected]
nullHi Raul Martinez
utl_smtp package is available since oracle 8.1.6.
If U have a older version then U can not.
Thank U.
edwin -
E-mail from oracle form - suppress dialog window
sending mail on commit using Oracle form4.5 - OLE2 built-in package.
The default mail is Microsoft office outlook 2003.
I get a microsoft office outlook dialog with the following message.
" A program is trying to automatically send e-mail on your behalf.
Do you want to allow this?
If this is unexpected, this may be virus and you should choose 'NO' "
In outlook express, there is a option to disable this. Under Tools -> Options -> Security tab : Warn me when other applications try to send mail as me'
Could anyone let me know as to how to suppress the dialog box please.Hi,
I've no idea how you can suppress such an message in MS Outlook. I'm a little bit surprised though, you have chosen an OLE2 approach. Why don't you simply send e-mail messages from the database using utl_smtp or utl_mail ?
Hope this helps,
Matthieu -
I have installed Oracle 10g (10.2.0.1) on Windows XP (SP2) machine at my home PC.There is a broadband connection on my home PC.I have installed UTL_MAIL package and then set SMTP_OUT_PARAMETER by the following SQL Statement.
My machine IP address is 192.168.0.3
SQl> alter system set smtp_out_server = 'smtp.bsnl.in:25' scope = 25;
Then we run the following script.
BEGIN
UTL_MAIL.SEND(
SENDER => '[email protected]',
RECIPIENTS => '[email protected]',
SUBJECT => 'Testing UTL_MAIL',
MESSAGE => 'The receipt of this email means'||
'that it works for UTL_MAIL'
END;
Then following error message comes.
BEGIN
ERROR at line 1:
ORA-29279: SMTP permanent error: 553 Authentication is required to send mail as
<[email protected]>
ORA-06512: at "SYS.UTL_SMTP", line 21
ORA-06512: at "SYS.UTL_SMTP", line 99
ORA-06512: at "SYS.UTL_SMTP", line 222
ORA-06512: at "SYS.UTL_MAIL", line 407
ORA-06512: at "SYS.UTL_MAIL", line 594
ORA-06512: at line 2
Can anybody suggest the solution of the above problem.Hi,
is your smtp server configured to use anonymous connection?
Attackwave
Reply Code Description
211 System status, or system help reply
214 Help message [Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user]
220 <domain> Service ready
221 <domain> Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
252 OK, pending messages for node <node> started. Cannot VRFY user (for example, info is not local), but will take message for this user and attempt delivery.
253 OK, <messages> pending messages for node <node> started
354 Start mail input; end with <CRLF>.<CRLF>
355 Octet-offset is the transaction offset
421 <domain> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down.)
450 Requested mail action not taken: mailbox unavailable [for example, mailbox busy]
451 Requested action terminated: local error in processing
452 Requested action not taken: insufficient system storage
453 You have no mail.
454 TLS not available due to temporary reason. Encryption required for requested authentication mechanism.
458 Unable to queue messages for node <node>
459 Node <node> not allowed: reason
500 Syntax error, command unrecognized (This may include errors such as command line too long.)
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
521 <Machine> does not accept mail.
530 Must issue a STARTTLS command first. Encryption required for requested authentication.
534 Authentication mechanism is too weak.
538 Encryption required for requested authentication mechanism.
550 Requested action not taken: mailbox unavailable [for , mailbox not found, no access]
551 User not local; please try <forward-path>
552 Requested mail action terminated: exceeded storage allocation
*553 Requested action not taken: mailbox name not allowed [for example, mailbox syntax incorrect]*
554 Transaction failed
Maybe you are looking for
-
Transfer data from one server to another server using idocs
hi,crm i have a data in crm system, i want to download this data and upload into another crm system by using idocs. please any one explain.
-
My online number is answered by a school in brookl...
I have had my online number for a couple of months and noticed that no one was using it. So i tried calling it. It is being answered by a school in brooklyn. Please credit my account and give me a working number
-
Microsoft Wireless Notebook Optical Mouse
For some reason I cannot get this mouse to work in windows (under bootcamp) or in OS X. It was originally working, but no more. Anyone have some ideas on how to get it working again?
-
Hi All I am trying to aquaint my self with the DataGuard concepts but I must admit I have limited knowledge/exposure into this side... when I have set-up the DR so as to ship archives from the primary to disaster recovery site geographically located
-
Hi, I'd like to programatically initiate a "find in files" search within a teststand sequence. Is this exposed in the teststand API anywhere? I am browsing the IEngine methods but all I see is "findfile" which isn't really what I want. thanks for