cagcowboy 2008-09-26T14:25:38
Looks like the HELO is the problem. Please can we check with a simple testcase...\n\nset serveroutput on\n\ndeclare\n lConnection UTL_SMTP.CONNECTION;\nbegin\n lConnection := UTL_SMTP.OPEN_CONNECTION(your_smtp_server);\n DBMS_OUTPUT.PUT_LINE('Opened ok');\n\n UTL_SMTP.HELO(lConnection, your_client_machine_name);\n DBMS_OUTPUT.PUT_LINE('HELO ok');\n\n UTL_SMTP.MAIL(lConnection, your_email_address);\n UTL_SMTP.RCPT(lConnection, your_email_address);\n DBMS_OUTPUT.PUT_LINE('Addressing ok');\nend;\n/\n",
Dan Maharry 2008-10-07T15:28:47
Looks like we've resolved this.\nTo answer the two questions.\n\n\nDouble check that the schema calling utl_smtp has execute permissions on sys.utl_smtp, sys.utl_tcp and sys.dbms_lob. Also check that at no time the message being sent is > 32Kb.\nNo there is no way to get utl_smtp to dump emails to a directory a la system.net.mail.\n\n\nThanks to cagcowboy for the help.",
Dan Maharry 2008-09-26T12:10:24
Yes, we can telnet to the server.\n\n-- ****** Object: Stored Procedure TRAVELADMIN_DEV.HTML_EMAIL Script Date: 22/08/2008 12:41:02 ******\nCREATE PROCEDURE \"HTML_EMAIL\" (\n p_to in varchar2,\n p_cc in varchar2,\n p_from in varchar2,\n p_subject in varchar2,\n p_text in varchar2 default null,\n p_html in varchar2 default null\n )\nis\n l_boundary varchar2(255) default 'a1b2c3d4e3f2g1';\n l_connection utl_smtp.connection;\n l_body_html clob := empty_clob; --This LOB will be the email message\n l_offset number;\n l_ammount number;\n l_temp varchar2(32767) default null;\n p_smtp_hostname varchar2(30):= 'rockies';\n p_smtp_portnum varchar2(2) := '25';\nbegin\n l_connection := utl_smtp.open_connection( p_smtp_hostname, p_smtp_portnum );\n utl_smtp.helo( l_connection, p_smtp_hostname );\n utl_smtp.mail( l_connection, p_from );\n utl_smtp.rcpt( l_connection, p_to );\n l_temp := l_temp || 'MIME-Version: 1.0' || chr(13) || chr(10);\n l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);\n IF ((p_cc <> NULL) OR (LENGTH(p_cc) > 0)) THEN\n l_temp := l_temp || 'Cc: ' || p_cc || chr(13) || chr(10);\n utl_smtp.rcpt( l_connection, p_cc );\n END IF;\n l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);\n l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);\n l_temp := l_temp || 'Reply-To: ' || p_from || chr(13) || chr(10);\n l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||\n chr(34) || l_boundary || chr(34) || chr(13) ||\n chr(10);\n ----------------------------------------------------\n -- Write the headers\n dbms_lob.createtemporary( l_body_html, false, 10 );\n dbms_lob.write(l_body_html,length(l_temp),1,l_temp);\n ----------------------------------------------------\n -- Write the text boundary\n l_offset := dbms_lob.getlength(l_body_html) + 1;\n l_temp := '--' || l_boundary || chr(13)||chr(10);\n l_temp := l_temp || 'content-type: text/plain; charset=us-ascii' ||\n chr(13) || chr(10) || chr(13) || chr(10);\n dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);\n ----------------------------------------------------\n -- Write the plain text portion of the email\n l_offset := dbms_lob.getlength(l_body_html) + 1;\n dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);\n ----------------------------------------------------\n -- Write the HTML boundary\n l_temp := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||\n chr(13) || chr(10);\n l_temp := l_temp || 'content-type: text/html;' ||\n chr(13) || chr(10) || chr(13) || chr(10);\n l_offset := dbms_lob.getlength(l_body_html) + 1;\n dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);\n ----------------------------------------------------\n -- Write the HTML portion of the message\n l_offset := dbms_lob.getlength(l_body_html) + 1;\n dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);\n ----------------------------------------------------\n -- Write the final html boundary\n l_temp := chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13);\n l_offset := dbms_lob.getlength(l_body_html) + 1;\n dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);\n ----------------------------------------------------\n -- Send the email in 1900 byte chunks to UTL_SMTP\n l_offset := 1;\n l_ammount := 1900;\n utl_smtp.open_data(l_connection);\n while l_offset < dbms_lob.getlength(l_body_html) loop\n utl_smtp.write_data(l_connection,\n dbms_lob.substr(l_body_html,l_ammount,l_offset));\n l_offset := l_offset + l_ammount ;\n l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);\n end loop;\n utl_smtp.close_data(l_connection);\n utl_smtp.quit( l_connection );\n dbms_lob.freetemporary(l_body_html);\nend;\n",