This content has been marked as final. Show 5 replies
Consult the SMTP protocol specifications:1 person found this helpful
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.
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
1 person found this helpful
984757 wrote:Also see this thread: UTL_MAIL: ORA-29279..... 501 badly formatted MAIL FROM user - no "<"
ERROR at line 1:
ORA-29279: SMTP permanent error: 501 Address Syntax Error in
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
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: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:firstname.lastname@example.org 501 Address Syntax Error in email@example.com
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:<firstname.lastname@example.org> 250 <email@example.com> Sender OK RCPT TO:<firstname.lastname@example.org> 250 <email@example.com> Recipient OK DATA 354 Enter mail, terminate with '.' alone on a line Some message....blah blah blah . 250 OK
I dislike UTL_MAIL - clunky and poor abstraction interface, and not well written.
Had a look at the code. It does this:
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.
WHILE (ALL_RCPTS IS NOT NULL) LOOP UTL_SMTP.RCPT(MAIL_CONN,'<' || GET_ADDRESS(ALL_RCPTS) || '>'); END LOOP;
The address is explicitly surrounded by brackets as per the RFC. So that is what your SMTP server should see.
SQL> var address varchar2(200); SQL> exec :address := '<firstname.lastname@example.org>,email@example.com'; PL/SQL procedure successfully completed. SQL> exec dbms_output.put_line( 'get_address='||UTL_MAIL.GET_ADDRESS(:address)||' address='||:address ); firstname.lastname@example.org email@example.com PL/SQL procedure successfully completed. SQL> exec dbms_output.put_line( 'get_address='||UTL_MAIL.GET_ADDRESS(:address)||' address='||:address ); firstname.lastname@example.org address= PL/SQL procedure successfully completed. SQL>
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)
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.