UTL_SMTP problem sending special characters
Hi there.
I'm passing through a send mail problem.
I maintain a system that send emails using the UTL_SMTP database package.
The procedure was going just fine, until the day the client migrated the version of Oracle database and the CHARSET configuration changed too. It’s migrated from Oracle 9i to Oracle 10g (Release 10.2.0.5.0).
Now the procedure can’t send any special characters like ‘áéíóúçÇÁÉÍÓÚ’, what’s is a critical problem to the system, because de emails are being classified as spams.
Following bellow the routine used to send emails:
-----
--...
conn UTL_SMTP.CONNECTION;
l_boundary VARCHAR2(50) := '----=*#abc1234321cba#*=';
--...
-- Open the SMTP connection ...
conn:= utl_smtp.open_connection( v_smtp_server, v_smtp_server_port );
-- Initial handshaking ...
UTL_SMTP.helo(conn, v_smtp_server);
UTL_SMTP.mail(conn, v_from_name);
UTL_SMTP.rcpt(conn, v_to_name);
UTL_SMTP.open_data(conn);
UTL_SMTP.write_data(conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, 'To: ' || v_to_name || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, 'From: ' || v_from_name || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, 'Subject: ' || subject || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, 'MIME-Version: 1.0' || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, 'Content-Type: multipart/alternative; boundary="' || l_boundary || '"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, '--' || l_boundary || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, *'Content-Type: text/html; charset="iso-8859-1"'* || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, v_message);
UTL_SMTP.write_data(conn, UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(conn, '--' || l_boundary || '--' || UTL_TCP.crlf);
UTL_SMTP.close_data(conn);
UTL_SMTP.quit(conn);
-----
Obs: Some more details about the charset database configuration:
NLS_CHARACTERSET: WE8MSWIN1252
NLS_LANGUAGE: AMERICAN
NLS_TERRITORY: AMERICA
NLS_NCHAR_CHARACTERSET: AL16UTF16