plsqlamazon-rdsamazon-ses

ORA-29279: SMTP permanent error: 504 The requested authentication mechanism is not supported


Trying to send email from AWS RDS (Oracle SE 19c) using Amazon SES relay which is configured and tested ( as I can send mail using SENDMAIL from Linux). I am using UTL_SMTP package and have given all required parameters. I have created Oracle wallet cwallet.sso and uploaded in Oracle directory as well. Can anyone throw some light why it's showing

ORA-29279: SMTP permanent error: 504 The requested authentication mechanism is not supported
ORA-06512: at "MMX.SEND_MAIL_HTML3", line 38
ORA-06512: at "SYS.UTL_SMTP", line 57
ORA-06512: at "SYS.UTL_SMTP", line 142
ORA-06512: at "SYS.UTL_SMTP", line 446
ORA-06512: at "MMX.SEND_MAIL_HTML3", line 20
ORA-06512: at line 14

Here is my code.

create or replace PROCEDURE SEND_MAIL_HTML3 (
    p_recipients  IN VARCHAR2,
    p_cc          IN VARCHAR2 DEFAULT NULL,
    p_bcc         IN VARCHAR2 DEFAULT NULL,
    p_subject     IN VARCHAR2,
    p_message     IN VARCHAR2)
IS
    c UTL_SMTP.CONNECTION;
    PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
    BEGIN
        UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
    END;
BEGIN   
    c := utl_smtp.open_connection(
              host => 'email-smtp.eu-central-1.amazonaws.com',
              port => 587,
              wallet_path => 'file://rdsdbdata/userdirs/01',
              secure_connection_before_smtp => FALSE);
    UTL_SMTP.STARTTLS(c);
    UTL_SMTP.AUTH(
        c => c,
        username => 'AWS_SES_ACCESS_KEY',
        password => 'AWS_SES_SECRET_KEY',
        schemes  => utl_smtp.all_schemes);
    UTL_SMTP.HELO(c, 'xxx.awsapps.com');
    UTL_SMTP.MAIL(c, 'xxx-do-no-reply@xxx.awsapps.com');
    UTL_SMTP.RCPT(c, p_recipients);
    UTL_SMTP.OPEN_DATA(c);
    send_header('From',    'XXX Dev Alert <xxx-do-no-reply@xxx.awsapps.com>');
    send_header('To',      p_recipients);
    send_header('Subject', p_subject);
    UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF || p_message);
    UTL_SMTP.CLOSE_DATA(c);
    UTL_SMTP.QUIT(c);
EXCEPTION
  WHEN OTHERS
  THEN
    RAISE;
END send_mail_html3;

Solution

  • The problem simply got resolved when I removed this line

    UTL_SMTP.HELO(c, 'xxx.awsapps.com');

    And added this line before UTL_SMTP.AUTH

    UTL_SMTP.EHLO(c, 'xxx.awsapps.com');

    It seems the handshaking was not done correctly which was causing to throw 504 The requested authentication mechanism is not supported