• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 678
  • Last Modified:

Sending email from Oracle PL/SQL

While trying to send email from Oracle Database I keep getting the following message.

ORA-20002: 553 Invalid RFC821 mailbox specification.

****
    This is the line of code that is returning the error.
    utl_smtp.rcpt(mailcomm, tooadd);
***

Any help is appreciated

Thanks
0
rajanvora
Asked:
rajanvora
2 Solutions
 
belemCommented:
Hi,

have you got more information?


yor variable mailcomm must have the type utl_smtp.open_connection

Example:
mailcomm:= utl_smtp.open_connection(192.168.1.1, 25);
and


your Variable tooadd is the email-adress of the Recepient.

Example: 'abc@gmx.net'


0
 
RamaDeviCommented:
Yes. I am OK with belem. The following example can help you more. Use the following call to execute the same.

execute SENDMAIL('to_mail@yahoo.com','oracle','subject','message');


CREATE or replace PROCEDURE SENDMAIL (TOO IN VARCHAR2, FROMM IN VARCHAR2,
   SUBJECT IN VARCHAR, BODY IN VARCHAR) AS

  CONN        UTL_SMTP.CONNECTION;
-- Set this to your SMTP mail server.
  SMTP_HOST   VARCHAR2(50)    := '127.0.0.1';
  PORT        VARCHAR2(2)     := 25;
  MSG_HEADER  VARCHAR2(2000)  := null;
  CR          VARCHAR2(2)     := chr(10)||chr(13);
  MSG_BODY    VARCHAR2(4000);

BEGIN
  CONN := UTL_SMTP.OPEN_CONNECTION(SMTP_HOST, PORT);
  MSG_HEADER := 'Date: ' ||
  TO_CHAR(SYSDATE, 'dd-Mon-yy hh24:mi:ss') || CR ||
  'From: <'||FROMM||'>' || CR ||
  'Subject: '||SUBJECT|| CR ||
  'To: '||TOO || CR ||
  '' || CR;

  MSG_BODY := MSG_HEADER || BODY;

  UTL_SMTP.HELO(CONN, SMTP_HOST);
  UTL_SMTP.MAIL(CONN, FROMM);
  UTL_SMTP.RCPT(CONN, TOO);
  UTL_SMTP.DATA(CONN, MSG_BODY);
  UTL_SMTP.QUIT(CONN);

END;
/
0
 
anand_2000vCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: belem {http:#8131949} & RamaDevi {http:#8156902}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

anand_2000v
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now