This discussion is archived
5 Replies Latest reply: Jan 30, 2013 4:05 AM by 987760 RSS

UTL.MAIL error ORA-29279: SMTP permanent error: 501 Address Syntax Error in

987760 Newbie
Currently Being Moderated
Hi,

I am new to the forum so please excuse if I post incorrectly without conforming to the standards.

We need to send mails using the UTL.MAIL package and have installed them on the database.
Whenever I am trying to send an email I am getting the following error:

ERROR at line 1:
ORA-29279: SMTP permanent error: 501 Address Syntax Error in
some_email_Address@domain.com
ORA-06512: at "SYS.UTL_MAIL", line 654
ORA-06512: at "SYS.UTL_MAIL", line 671
ORA-06512: at line 2

The test code which I am running is as follows:

BEGIN
UTL_MAIL.send(sender => 'test <some_email_Address@domain.com>',
recipients => 'operator@xyz.com',
subject => 'UTL_MAIL test subject',
message => 'UTL_MAIL test body');
END;

I have tried different combinations:

BEGIN
UTL_MAIL.send(sender => 'test "<some_email_Address@domain.com>"',
recipients => 'operator@xyz.com',
subject => 'UTL_MAIL test subject',
message => 'UTL_MAIL test body');
END;

even tried

BEGIN
UTL_MAIL.send(sender => 'some_email_Address@domain.com',
recipients => 'operator@xyz.com',
subject => 'UTL_MAIL test subject',
message => 'UTL_MAIL test body');
END;

Everytime I am getting the same error.
This seems to be working with an exchange mail server but never on the SMTP server.

In the SMTP server logs the sender address is not having the angular brackets <> unlike the other mails which are being sent over.
It seems that the SMTP server is pretty strict and the SMTP admin will not change any settings on the server.

The oracle version is as follows

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

Could you please help me out with a solution.
Some how the angular brackets are geting stripped off (which UTL MAIL package generally does), Is there any way in which I can include the angular brackets.

Edited by: 984757 on 29-Jan-2013 02:56

Edited by: 984757 on 29-Jan-2013 02:57
  • 1. Re: UTL.MAIL error ORA-29279: SMTP permanent error: 501 Address Syntax Error in
    BillyVerreynne Oracle ACE
    Currently Being Moderated
    Consult the SMTP protocol specifications:
    https://tools.ietf.org/html/rfc821
    
             The second step in the procedure is the RCPT command.
    
                RCPT <SP> TO:<forward-path> <CRLF>
    
             This command gives a forward-path identifying one recipient.
             If accepted, the receiver-SMTP returns a 250 OK reply, and
             stores the forward-path.  If the recipient is unknown the
             receiver-SMTP returns a 550 Failure reply.  
    Example:
    https://tools.ietf.org/html/rfc821
    
             This SMTP example shows mail sent by Smith at host Alpha.ARPA,
             to Jones, Green, and Brown at host Beta.ARPA.  Here we assume
             that host Alpha contacts host Beta directly.
    
                S: MAIL FROM:<Smith@Alpha.ARPA>
                R: 250 OK
    
                S: RCPT TO:<Jones@Beta.ARPA>
                R: 250 OK
    
                S: RCPT TO:<Green@Beta.ARPA>
                R: 550 No such user here
    
                S: RCPT TO:<Brown@Beta.ARPA>
                R: 250 OK
  • 2. Re: UTL.MAIL error ORA-29279: SMTP permanent error: 501 Address Syntax Error in
    stefan nebesnak Journeyer
    Currently Being Moderated
    984757 wrote:

    ERROR at line 1:
    ORA-29279: SMTP permanent error: 501 Address Syntax Error in
    some_email_Address@domain.com
    Also see this thread: UTL_MAIL: ORA-29279..... 501 badly formatted MAIL FROM user - no "<"
  • 3. Re: UTL.MAIL error ORA-29279: SMTP permanent error: 501 Address Syntax Error in
    987760 Newbie
    Currently Being Moderated
    Hi Billy,

    Thanks for sharing the RFC.
    The problem is due to the fact that when the SMTP server is invoked, the MAIL FROM information is getting stripped of the angular brackets and tha is the reason I am getting the error. If somehow I could pass the angular brackets (I guess the utl mail package is stripping them off)-
    If I try to directly use the SMTP services from the server I get the same error message if I do not set the angular brackets as seen below
    telnet XXX.XX.XX.XX 25
    Trying XXX.XX.XX.XX...
    Connected to XXX.XX.XX.XX.
    Escape character is '^]'.
    220 smtp.xxx.xxxx ESMTP ready at Tue, 29 Jan 2013 11:28:38 +0000
    EHLO
    250-xxx.xxxx 
    250-SIZE 25600000
    250-8BITMIME
    250-AUTH=LOGIN PLAIN CRAM-MD5
    250 AUTH LOGIN PLAIN CRAM-MD5
    MAIL FROM:some_email_address@domain.xxxx
    501 Address Syntax Error in some_email_address@domain.xxxx
    When the angular brackets are present - the mail is proper
    telnet xxx.xx.xx.xx 25
    Trying xxx.xx.xx.xx...
    Connected to xxx.xx.xx.xx.
    Escape character is '^]'.
    220 smtp.xxx.xxxx ESMTP ready at Tue, 29 Jan 2013 11:33:31 +0000
    EHLO
    250-smtp.xxx.xxxx
    250-SIZE 25600000
    250-8BITMIME
    250-AUTH=LOGIN PLAIN CRAM-MD5
    250 AUTH LOGIN PLAIN CRAM-MD5
    MAIL FROM:<some_email_address@domain.xxxx>
    250 <some_email_address@domain.xxxx> Sender OK
    RCPT TO:<recepient_email_address@domain.xxxx>
    250 <recepient_email_address@domain.xxxx> Recipient OK
    DATA
    354 Enter mail, terminate with '.' alone on a line
    Some message....blah blah blah
    .
    250 OK
  • 4. Re: UTL.MAIL error ORA-29279: SMTP permanent error: 501 Address Syntax Error in
    BillyVerreynne Oracle ACE
    Currently Being Moderated
    I dislike UTL_MAIL - clunky and poor abstraction interface, and not well written.

    Had a look at the code. It does this:
    WHILE (ALL_RCPTS IS NOT NULL) LOOP
          UTL_SMTP.RCPT(MAIL_CONN,'&lt;' || GET_ADDRESS(ALL_RCPTS) || '&gt;');
    END LOOP;
    The GET_ADDRESS() function process the ALL_RCPTS parameter, returns the 1st address from it, and updates the (in/out) parameter with the remaining string.
    SQL> var address varchar2(200);
    SQL> exec :address := '<user@domain.com>,user2@domain.com';
    
    PL/SQL procedure successfully completed.
    
    SQL> exec dbms_output.put_line( 'get_address='||UTL_MAIL.GET_ADDRESS(:address)||' address='||:address );
    get_address=user@domain.com address=user2@domain.com
    
    PL/SQL procedure successfully completed.
    
    SQL> exec dbms_output.put_line( 'get_address='||UTL_MAIL.GET_ADDRESS(:address)||' address='||:address );
    get_address=user2@domain.com address=
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    The address is explicitly surrounded by brackets as per the RFC. So that is what your SMTP server should see.

    If not - perhaps then our UTL_MAIL versions do not match. Cannot recall from what version I pulled and unwrapped the UTL_MAIL package code I have.

    Personally though, I've ceased using UTL_MAIL a while back. It lacks in may respects. I have written my own mail package that supports multiple attachment, complex Mime formatting, attachments of 20+ MB in size, and so on - running on the UTL_SMTP interface (that provides the transport layer for sending mail). And for issues like you are facing, I suggest considering using UTL_SMTP directly.

    Edited by: Billy Verreynne on Jan 29, 2013 12:52 PM
    (Updated the code with HTML entity names to get the code snippet to render correctly)
  • 5. Re: UTL.MAIL error ORA-29279: SMTP permanent error: 501 Address Syntax Error in
    987760 Newbie
    Currently Being Moderated
    Thanks Billy, I have re-written the procedure using UTL_SMTP as suggested.
    UTL_MAIL really is not which can be relied upon it seems.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points