Hi,
Using : APEX 5.1, Oracle 11.2
I'm trying to use an external SMTP server to send e-mails from APEX using apex_mail.send.
The mails fail and in the mail queue I see the error : ORA-29279: Permanent SMTP-failure: 535 authentication failed (#5.7.1)
When using the same parameters with utl_smtp the mails are send correctly.
The external SMTP mailserver requires authentication.
Is this a bug or limited functionality of apex_mail or am I doing something wrong ?
I configure the settings using the code below but the same behaviour happends when using the apex instance admin gui
BEGIN
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_HOST_ADDRESS','<<servername>>');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_HOST_PORT','587');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_TLS_MODE','N');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_USERNAME','<<username>>');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_FROM','<<from_mail_address>>');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_PASSWORD','<<password>>');
APEX_INSTANCE_ADMIN.SET_PARAMETER('WALLET_PATH','file:/u01/app/oracle/wallet/mail/wallet');
APEX_INSTANCE_ADMIN.SET_PARAMETER('WALLET_PWD','<<wallet password>>');
COMMIT;
END;
after sending an e-mail with apex_mail.send the mail fails. I also tried all other variant of the SMTP_TLS_MODE parameter but all fail.
If I use the same parameters with utl_smtp the mail is send correctly. Code looks something like this :
l_mail_conn := utl_smtp.open_connection( host => p_smtp_host,
port => p_smtp_port,
wallet_path => 'file:/u01/app/oracle/wallet/mail/wallet',
wallet_password => '<<wallet password>>',
secure_connection_before_smtp => FALSE);
UTL_SMTP.HELO(l_mail_conn, '<<apex servername>>');
UTL_SMTP.STARTTLS(l_mail_conn);
UTL_SMTP.HELO(l_mail_conn, '<<apex servername>>');
utl_smtp.command( l_mail_conn, 'AUTH LOGIN');
utl_smtp.command( l_mail_conn, '<<base 64 encoded username>>'); -- BASE64ENCODE USERNAMNE
utl_smtp.command( l_mail_conn, '<<base 64 encoded password>>'); -- BASE64ENCODE pwd
UTL_SMTP.mail(l_mail_conn, p_from);
UTL_SMTP.rcpt(l_mail_conn, p_to);
UTL_SMTP.open_data(l_mail_conn);
UTL_SMTP.write_data(l_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'To: ' || p_to || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'From: ' || p_from || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || p_subject || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'Reply-To: ' || p_from || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'MIME-Version: 1.0' || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'Content-Type: multipart/alternative; boundary="' || l_boundary || '"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, 'Content-Type: text/plain; charset="UTF-8"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, p_text_msg);
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || '--' || UTL_TCP.crlf);
UTL_SMTP.close_data(l_mail_conn);
UTL_SMTP.quit(l_mail_conn);
In APEX I also tried using the base64 encoded username and password with same error result, but I assume the base64 encoding is already done via apex_mail (but it was worth trying).
Regards
Bas