Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
221 vnguyen 1
CREATE PROCEDURE "RELEASE_MANAGER"."RELEASE_MANAGER_MAILOUT" (
2
  sender      IN VARCHAR2,
3
  recipient   IN VARCHAR2,
4
  ccrecipient IN VARCHAR2,
5
  subject     IN VARCHAR2,
6
  message     IN VARCHAR2
7
  ) IS
8
 
9
  crlf VARCHAR2(2):= UTL_TCP.CRLF;
10
  connection utl_smtp.connection;
11
  mailhost VARCHAR2(30) := 'aupera03.aupera.erggroup.com';
12
  header VARCHAR2(1000);
13
 
14
BEGIN
15
 
16
  --
17
  -- Start the connection.
18
  --
19
  connection := utl_smtp.open_connection(mailhost,25);
20
 
21
  header:= 'Date: '||TO_CHAR(SYSDATE,'dd Mon yy hh24:mi:ss')||crlf||
22
     'From: '||sender||''||crlf||
23
  'Subject: '||subject||crlf||
24
       'To: '||recipient||crlf||
25
       'CC: '||ccrecipient;
26
 
27
  --
28
  -- Handshake with the SMTP server
29
  --
30
  utl_smtp.helo(connection, mailhost);
31
  utl_smtp.mail(connection, sender);
32
  utl_smtp.rcpt(connection, recipient);
33
  utl_smtp.rcpt(connection, ccrecipient);
34
  utl_smtp.open_data(connection);
35
  --
36
  -- Write the header
37
  --
38
  utl_smtp.write_data(connection, header);
39
  --
40
  -- The crlf is required to distinguish that what comes next is not simply part of the header..
41
  --
42
  utl_smtp.write_data(connection, crlf ||message);
43
  utl_smtp.close_data(connection);
44
  utl_smtp.quit(connection);
45
 
46
EXCEPTION
47
  WHEN UTL_SMTP.INVALID_OPERATION THEN
48
    dbms_output.put_line(' Invalid Operation in SMTP transaction.');
49
  WHEN UTL_SMTP.TRANSIENT_ERROR THEN
50
    dbms_output.put_line(' Temporary problems with sending email - try again later.');
51
  WHEN UTL_SMTP.PERMANENT_ERROR THEN
52
    dbms_output.put_line(' Errors in code for SMTP transaction.');
53
 
54
END RELEASE_MANAGER_MAILOUT;
55
/