Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SMTP ERROR When using APEX_EMAIL, but UTL_SMTP works OK. (HELO Greeting)

Richard LeggeJun 11 2015 — edited Jun 11 2015

Hi All,

APEX 4.2.5  XE 11.2

My latest issue, Im trying to get APEX_EMAIL working. I can send an email, but its being rejected by the SMTP Server Im trying to send to with error:

ORA-29279: SMTP permanent error: 550 You're not me.

If I send an email using UTL_SMTP to the same SMTP Server, the mail is not rejected and the receipient receives the email.

I Ive tried another SMTP Server and the message is a little clearer (customised), and relates to the HELO not being correct. the message is as follows:

ORA-29279: SMTP permanent error: 554 5.7.1 <smtp.vodacom.co.za>: Helo command rejected: You are not Vodacom. Please change your "HELO" greeting.

UTL_SMTP gives you the opportunity to set & send a HELO greeting in the form:

  c := UTL_SMTP.OPEN_CONNECTION('mymail.test.co.za');

  UTL_SMTP.HELO(c, 'foo.com');

However the APEX_MAIL API doesn't appear let you do so..   Ive spent the day researching to see if there is a way to set the HELO greeting/message, but cannot find anything..

My code for both is the following:

APEX_MAIL.send     --   Not working...

begin

APEX_MAIL.send (          p_to =>  'email@somewhere.com',

                          p_from => 'someone@somewhere.com',

                          p_body => 'Hello World',

                          p_body_html => ' Data in HTML format ',

                          p_SUBJ => 'Subject of your email',

                          p_cc => NULL,

                          p_bcc => NULL ,

                          p_replyto => NULL

                         );

end;

UTL_SMTP    -- Working....

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('mymailserver.co.za');

  UTL_SMTP.HELO(c, 'foo.com');

  UTL_SMTP.MAIL(c, 'sender@foo.com');

  UTL_SMTP.RCPT(c, 'email@somewhere.com');

  UTL_SMTP.OPEN_DATA(c);

  send_header('From',    '"Sender" <sender@foo.com>');

  send_header('To',      '"Recipient" <email@somewhere.com>');

  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;

many thanks

Richard

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 9 2015
Added on Jun 11 2015
3 comments
644 views