user3138025
user3138025

Reputation: 825

Basic Authentication removed by Microsoft recently. Is there another way an Oracle app can use SMTP from a Hotmail account?

I'm using Oracle 21.C. I have been using Oracle's UTIL_SMTP for years to send mailings from a Hotmail account. From what I understand, Microsoft recently sunset "Basic Authentication" for logging in as Microsoft. Microsoft doesn't seem to have alternatives for single-user hotmail accounts. Is anyone aware of a way to authenticate to Microsoft using Oracle's SMTP? Here's the sample code I have:

--This test procedure now fails on the utl_smtp.auth statement on line 65
DECLARE
    l_smtp_hostname       varchar2(1024);
    l_smtp_port           varchar2(1024);
    l_wallet_path         varchar2(1024);
    l_wallet_password     varchar2(1024);
    l_domain              varchar2(1024);
    l_smtp_username       varchar2(1024);
    l_smtp_password       varchar2(1024);
    l_source_app          varchar2(1024);
    l_location            varchar2(1024);
    l_smtp_conn           utl_smtp.connection;
    l_smtp_reply          utl_smtp.reply;
    l_smtp_replies        utl_smtp.replies;
BEGIN
    l_smtp_hostname     := 'outlook.office365.com';
    l_smtp_port         := '587';
    l_domain            := 'hotmail.com';
    l_smtp_username     := '[email protected]';
    l_smtp_password     := 'mYpASSWORD';
    l_source_app        := '111';
    l_wallet_path       := 'My Wallet Path';
    l_wallet_password   := 'My Wallet Password';

    -- Open the initial connection
    l_location := 'utl_smtp.OPEN_CONNECTION';
    l_smtp_reply := utl_smtp.open_connection 
        ( host                              => l_smtp_hostname
        , port                              => l_smtp_port
        , c                                 => l_smtp_conn
        , wallet_path                       => l_wallet_path
        , wallet_password                   => l_wallet_password
        , secure_connection_before_smtp     => FALSE
        ); 
    If l_smtp_reply.code != 220
    Then
        Insert into mail_error_log (err_code, err_msg, transaction_type, 
                    transaction_detail, source_app, code_location) 
            values (l_smtp_reply.code, l_smtp_reply.text, 'utl_smtp', 
            l_smtp_reply.code, l_source_app, l_location);
            commit;    
    End If;

    --Send the first EHLO
    l_location := 'utl_smtp.EHLO - First';
    l_smtp_replies := utl_smtp.ehlo(l_smtp_conn, l_smtp_hostname);
    --Send the StartTLS command
    l_location := 'utl_smtp.STARTTLS';
    l_smtp_reply := utl_smtp.starttls(l_smtp_conn);
    If l_smtp_reply.code != 220
      Then
        Insert into mail_error_log (err_code, err_msg, transaction_type, 
                    transaction_detail, source_app, code_location) 
            values (l_smtp_reply.code, l_smtp_reply.text, 'utl_smtp', 
            l_smtp_reply.code, l_source_app, l_location);
            commit;    
    End If;

    --Send the second EHLO command    
    l_location := 'utl_smtp.EHLO - Second';
    l_smtp_replies := utl_smtp.ehlo(l_smtp_conn, l_domain);

    --Send the Authentication statement 
    l_location := 'utl_smtp.AUTH';
    l_smtp_reply := utl_smtp.auth(l_smtp_conn, l_smtp_username, l_smtp_password, utl_smtp.all_schemes);
    If l_smtp_reply.code != 235
    Then
        Insert into mail_error_log (err_code, err_msg, transaction_type, 
                    transaction_detail, source_app, code_location) 
            values (l_smtp_reply.code, l_smtp_reply.text, 'utl_smtp', 
            l_smtp_reply.code, l_source_app, l_location);
            commit;    
    End If;

    --Call the Quit statement
    utl_smtp.quit(l_smtp_conn);

EXCEPTION
    When    utl_smtp.transient_error
       Or utl_smtp.permanent_error
    Then
      Begin
        utl_smtp.quit(l_smtp_conn);
      Exception
        When    utl_smtp.transient_error
          Or utl_smtp.permanent_error
        Then
          Null;
      End;
END;

Upvotes: 0

Views: 86

Answers (1)

The solution to this is a proxy SMTP server that then uses fancy authentication to send the mail out using the hotmail account. The proxy can be a local instance of postfix for example, or even something much simpler.

Upvotes: 0

Related Questions