sending email through oracle 9i procedure outside the domain

Below is my procedure (html_email).  It compiles and runs.  It successfully sends an html email to the specified address that is hard coded in the to field.  Here is the problem, it will only send an email if the "to" email address is in the same domain as the mail server.  Meaning, the mail server is mail.cs.um.edu and the "to" field is test001@um.edu..................that will work.   BUT, if the "to" field is testing@hotmail.com, it wont send anything.  How can I get this smtp proc to send to emails outside the domain?!?!?!?!  THanks in advance.  PS, I have a similar proc that I have used in the past on the same server, and it can send mail outside the domain without problems.. I have that proc(results_action) listed below as well.





 procedure html_email
is
   
      
    p_to             varchar2(50) := 'test001@um.edu';
    p_from           varchar2(50) := 'mints@um.edu';
    p_subject        varchar2(50) := 'test subject';
    p_text           varchar2(50) := 'testing';
    p_html           varchar2(50) := '<b>testing</b>' || '<ul><li>tesing</li></ul>' ;
    p_smtp_hostname  varchar2(50) := 'mail.cs.um.edu';
    p_smtp_portnum   varchar2(50) := 25;
      
      
      
      
      
      l_boundary      varchar2(255) default 'a1b2c3d4e3f2g1';
    l_connection    utl_smtp.connection;
    l_body_html     clob := empty_clob;  --This LOB will be the email message
    l_offset        number;
    l_ammount       number;
    l_temp          varchar2(32767) default null;
begin
    l_connection := utl_smtp.open_connection( p_smtp_hostname, p_smtp_portnum );
    utl_smtp.helo( l_connection, p_smtp_hostname );
    utl_smtp.mail( l_connection, p_from );
    utl_smtp.rcpt( l_connection, p_to );

    l_temp := l_temp || 'MIME-Version: 1.0' ||  chr(13) || chr(10);
    l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
    l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
    l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
    l_temp := l_temp || 'Reply-To: ' || p_from ||  chr(13) || chr(10);
    l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
                         chr(34) || l_boundary ||  chr(34) || chr(13) ||
                         chr(10);

    ----------------------------------------------------
    -- Write the headers
    dbms_lob.createtemporary( l_body_html, false, 10 );
    dbms_lob.write(l_body_html,length(l_temp),1,l_temp);


    ----------------------------------------------------
    -- Write the text boundary
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    l_temp   := '--' || l_boundary || chr(13)||chr(10);
    l_temp   := l_temp || 'content-type: text/plain; charset=us-ascii' ||
                  chr(13) || chr(10) || chr(13) || chr(10);
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);

    ----------------------------------------------------
    -- Write the plain text portion of the email
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);

    ----------------------------------------------------
    -- Write the HTML boundary
    l_temp   := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
                    chr(13) || chr(10);
    l_temp   := l_temp || 'content-type: text/html;' ||
                   chr(13) || chr(10) || chr(13) || chr(10);
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);

    ----------------------------------------------------
    -- Write the HTML portion of the message
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);

    ----------------------------------------------------
    -- Write the final html boundary
    l_temp   := chr(13) || chr(10) || '--' ||  l_boundary || '--' || chr(13);
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);


    ----------------------------------------------------
    -- Send the email in 1900 byte chunks to UTL_SMTP
    l_offset  := 1;
    l_ammount := 1900;
    utl_smtp.open_data(l_connection);
    while l_offset < dbms_lob.getlength(l_body_html) loop
        utl_smtp.write_data(l_connection,
                            dbms_lob.substr(l_body_html,l_ammount,l_offset));
        l_offset  := l_offset + l_ammount ;
        l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
    end loop;
    utl_smtp.close_data(l_connection);
    utl_smtp.quit( l_connection );
    dbms_lob.freetemporary(l_body_html);


end;



PROCEDURE results_action
--    IS
--       CURSOR email_data_cur
--       IS
--          SELECT email from testing where email is not null;
--
--       email_data_cur_rec   email_data_cur%ROWTYPE;
--       sendoraddress        VARCHAR2 (30)            := 'asdf@um.edu';
--      -- cc_mail              VARCHAR2 (30)            := 'asdf@um.edu';
--       receiveraddress      VARCHAR (60);
--       emailserver          VARCHAR2 (30)            := 'mail.cs.um.edu';
--       port                 NUMBER                   := 25;
--       conn                 UTL_SMTP.connection;
--       crlf                 VARCHAR2 (2)             := CHR (13) || CHR (10);
--       mesg                 VARCHAR2 (4000);
--       mesg_body            VARCHAR2 (4000);
--   --    mime_type           VARCHAR2 (30)            := 'text/html';
--    BEGIN
--       FOR email_data_cur_rec IN email_data_cur
--       LOOP
--          conn := UTL_SMTP.open_connection (emailserver, port);
--          UTL_SMTP.helo (conn, emailserver);
--          UTL_SMTP.mail (conn, sendoraddress);
--       --      write_mime_header(conn, 'Content-Type', mime_type);
--        --  UTL_SMTP.rcpt (conn, cc_mail);
--          receiveraddress := email_data_cur_rec.email;
--          mesg :=
--                'Date: '
--             || TO_CHAR (SYSDATE, 'dd Mon yy hh24:mi:ss')
--             || crlf
--             || 'From:'
--             || sendoraddress
--             || crlf
--             || 'Subject: Study Newsletter'
--             || crlf
--             || 'To: '
--             || receiveraddress
--             || crlf
--             || ''
--       'you do not wish to receive .'
--        UTL_SMTP.rcpt (conn, receiveraddress);
--          UTL_SMTP.DATA (conn, mesg);
--          UTL_SMTP.quit (conn);
--

-- --
-- --          COMMIT;
--        END LOOP;
mintsiiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RCorfmanCommented:
Is the mail server rejecting the request right away? If so, what error are you getting?  If the mail appears to go out, the reciever says it didn't get there, is the 'from' email address getting an error message returned to it?  The admins on the mail server may have set it up so some outgoing mail is filtered... this would be in an effort to prevent viruses.  You can certainly check with the mail gateway administrator and see if they saw the mail and blocked it... I suspect that is the problem.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.