PL/SQL Mail Utility :: Binary/Ascii/Cc/Bcc/FileDump

I was working on my mail package and decided it was overtly complicated and
stripped it down to its bare bones. Here is what I came up with. Built on a previous
foundation of anothers work, I expanded the functionality considerably. You will find all
the features I think that you will need regarding a mail routine. There is also a nice
filedump routine included which makes very easy to create flat file dumps that you can
then attach to your emails. There are a few pre-reqs in using this though :
- 9iR2+
- DBA_Directories defined as opposed to utl_file paths
- Java Virtual Machine. Document can be found in “Note :105472.1 Setup, Configuration,
and Use of the Java Virtual Machine” on metalink.
As always, I welcome feedback and suggestions for improvement.
Barry C
http://www.myoracleportal.com
CREATE OR REPLACE PACKAGE mail_tools
AS
-- SENDMAIL supports variable message length with/without attachments
-- QUERY_SERVER allows you to check the status of a mail server to see if it is running
-- DUMP_FLATFILE allows you to dump flat file data from query submitted
-- Query Server to verify that the server is up and running.
-- Connects, Noop Command is executed, Disconnect.
-- GET_MAIL_ADDRESS is utilized in the SENDMAIL procedure
-- Table 100-3 SMTP Reply Codes
-- Reply Code
-- Meaning
-- 211 System status, or system help reply
-- 214 Help message [Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user]
-- 220 <domain> Service ready
-- 221 <domain> Service closing transmission channel
-- 250 Requested mail action okay, completed
-- 251 User not local; will forward to <forward-path>
-- 252 OK, pending messages for node <node> started. Cannot VRFY user (e.g., info is not local), but will take message for this user and attempt delivery.
-- 253 OK, <messages> pending messages for node <node> started
-- 354 Start mail input; end with <CRLF>.<CRLF>
-- 355 Octet-offset is the transaction offset
-- 421 <domain> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down.)
-- 450 Requested mail action not taken: mailbox unavailable [for example, mailbox busy]
-- 451 Requested action aborted: local error in processing
-- 452 Requested action not taken: insufficient system storage
-- 453 You have no mail.
-- 454 TLS not available due to temporary reason. Encryption required for requested authentication mechanism.
-- 458 Unable to queue messages for node <node>
-- 459 Node <node> not allowed: reason
-- 500 Syntax error, command unrecognized (This may include errors such as command line too long.)
-- 501 Syntax error in parameters or arguments
-- 502 Command not implemented
-- 503 Bad sequence of commands
-- 504 Command parameter not implemented
-- 521 <Machine> does not accept mail.
-- 530 Must issue a STARTTLS command first. Encryption required for requested authentication mechanism.
-- 534 Authentication mechanism is too weak.
-- 538 Encryption required for requested authentication mechanism.
-- 550 Requested action not taken: mailbox unavailable [for , mailbox not found, no access]
-- 551 User not local; please try <forward-path>
-- 552 Requested mail action aborted: exceeded storage allocation
-- 553 Requested action not taken: mailbox name not allowed [for example, mailbox syntax incorrect]
-- 554 Transaction failed
This version allows for a customized seperator value. Using this function will allow you to
perform fixed width flat files by defining '' for no seperator and then RPAD/LPAD your columns as necessary.
Or use whatever seperator you wish to use, pipe, space, zeros, etc.
   --  Example : This will generate a flat file which tabbed seperated
-- DECLARE
--    l_rows   NUMBER;
--    l_sql    VARCHAR2(32000);
-- BEGIN
--    l_sql := '
-- SELECT   rpad(hou.NAME,70) udn_desc
-- ,        rpad(pcak.segment1,6) coid
-- ,        rpad(pcak.segment2,4) udn
--     FROM hr_all_organization_units hou, hr.pay_cost_allocation_keyflex pcak
--    WHERE TRUNC (SYSDATE) BETWEEN hou.date_from
--                              AND NVL (hou.date_to, ''31-DEC-4712'')
--      AND pcak.cost_allocation_keyflex_id = hou.cost_allocation_keyflex_id
-- GROUP BY pcak.segment1, pcak.segment2, hou.NAME
-- ORDER BY 1, 2, 3
--    l_rows :=
--       dump_flatfile
--          (p_query          =>
-- ,         p_dir            => 'INTF000_TABLES'
-- ,         p_filename       => 'test.csv'
-- ,       p_separator     => '     ' -- <= tabbed 5 spaces between each column
-- ,       p_max_linesize   => 32000
-- ,       p_mode       => 'w' -- (w)rite mode or (a)ppend mode
-- END;
   FUNCTION dump_flatfile (
      p_query                    IN       VARCHAR2
,     p_dir                      IN       VARCHAR2
,     p_filename                 IN       VARCHAR2
,     p_separator                IN       VARCHAR2
,     p_headers                  IN       BOOLEAN DEFAULT FALSE
,     p_trailing_separator       IN       BOOLEAN DEFAULT FALSE
,     p_max_linesize             IN       NUMBER DEFAULT 32000
,     p_mode                     IN       VARCHAR2 DEFAULT 'w' )
      RETURN NUMBER;
   FUNCTION get_mail_address (
      addr_list                  IN OUT   VARCHAR2 )
      RETURN VARCHAR2;
   FUNCTION smtp_command (
      command                    IN       VARCHAR2
,     ok                         IN       VARCHAR2 DEFAULT '250'
,     code                       OUT      VARCHAR2
,     DEBUG                               NUMBER DEFAULT 0 )
      RETURN BOOLEAN;
   FUNCTION query_server (
      smtp_server                         VARCHAR2
,     smtp_server_port                    PLS_INTEGER DEFAULT 25
,     DEBUG                               NUMBER DEFAULT 0 )
      RETURN BOOLEAN;
This procedure uses the UTL_TCP package to send an email message.
Up to three file names may be specified as attachments.
Written: Dave Wotton, 14/6/01 (Cambridge UK)
This script comes with no warranty or support. You are free to
modify it as you wish, but please retain an acknowledgement of
my original authorship.
Amended: Dave Wotton, 10/7/01
Now uses the utl_smtp.write_data() method to send the message,
eliminating the 32Kb message size constraint imposed by the
utl_smtp.data() procedure.
Amended: Dave Wotton, 20/7/01
Increased the v_line variable, which holds the file attachment
lines from 400 to 1000 bytes. This is the maximum supported
by RFC2821, The Simple Mail Transfer Protocol specification.
Amended: Dave Wotton, 24/7/01
Now inserts a blank line before each MIME boundary line. Some
mail-clients require this.
Amended: Dave Wotton, 4/10/01
Introduced a 'debug' parameter. Defaults to 0. If set to
non-zero then errors in opening files for attaching are
reported using dbms_output.put_line.
Include code to hand MS Windows style pathnames.
Amended: Barry Chase, 4/29/03
Added Priority to procedure and also X-Mailer ID.
Removed restrictions for email size limitation as well.
Emails are now formatted text messages, meaning you can
write your message in html format.
And finally, changed from using UTL_SMTP to UTL_TCP instead.
Amended: Barry Chase 11/10/2003
Added session timeout of 4 minutes to prevent hanging server connections
Amended: Barry Chase 12/04/2003
Added Date String so that it represents timezone of originating server
p_datestring
Amended: Barry Chase 03/01/2004
Added functionality to support binary attachments and remote attachments.
Its about 98% complete. Not work perfectly yet. Still trying to figure out
encoding to base64 or mime. Have a good start on it though.
04/12/2004
BCHASE :: Binary Support is fully functional now.
09/01/2005
BCHASE :: Modified attachment directories to use DBA_DIRECTORIES instead
of UTL_DIR in the Oracle initialization file.
02/22/2006
BCHASE :: Added variable length message email support (CLOB)
04/21/2006
BCHASE :: Expanded functionality to include Cc and Bcc
Also removed redundant calls from package. The single
mail_files command will handle flat files and binary files such as zip/pdf/etc.
SMTP Server and SMTP Server Port are parameters on the sendmail procedure now
as well.
Refer to http://home.clara.net/dwotton/dba/oracle_smtp.htm for more
details on the original source code.
For information on the enhanced mail_tools package as provided by Barry
Chase, refer to http://www.myoracleportal.com
   /* Retrieves local binary file from database server.
    * using DBMS_LOB commands and stores into BLOB
    * return BLOB
   FUNCTION get_local_binary_data (
      p_dir                      IN       VARCHAR2
,     p_file                     IN       VARCHAR2 )
      RETURN BLOB;
/* Supports binary attachments and message of variable length. Uses CLOB.*/
-- DECLARE
-- t_blob BLOB;
-- BEGIN
-- Use the get_local_binary_data to collect your BLOB from the filesystem
-- or just load from a table where your BLOB is stored at, then just pass
-- as t_blob on the binaryfile parameter below. Remember to provide an
-- appropriate filename. Optionally, you can leave filename NULL and pass
-- the binaryfile parameter as EMPTY_BLOB() to send an email without an
-- attachment.
--   t_blob :=
--    mail_tools.get_local_binary_data
--                   ( p_dir =>                         'INTF0047_TABLES'
--,                    p_file =>                        'test_file1.csv' );
--    mail_tools.sendmail
--             ( smtp_server =>                   'your.smtp.server'
-- ,             smtp_server_port =>              25
-- ,             from_name =>                     'Email Address of Sender'
-- ,             to_name =>                       'list of TO email addresses separated by commas (,)'
-- ,             cc_name =>                       'list of CC email addresses separated by commas (,)'
-- ,             bcc_name =>                      'list of BCC email addresses separated by commas (,)'
-- ,             subject =>                       'Some brief Subject'
-- ,             MESSAGE =>                       'Your message goes here. Can include HTML code.'
-- ,             priority =>                      '1-5 1 being the highest priority and 3 normal priority'
-- ,             filename =>                      'your.filename.txt or leave NULL'
-- ,             binaryfile =>                    'your blob is passed here otherwise leave as EMPTY_BLOB()
-- ,             DEBUG =>                         'Default is DBMS output otherwise pass a 1 to disable );
-- END;
   PROCEDURE sendmail (
      smtp_server                         VARCHAR2
,     smtp_server_port                    PLS_INTEGER DEFAULT 25
,     from_name                           VARCHAR2
,     to_name                             VARCHAR2
,     cc_name                             VARCHAR2 DEFAULT NULL
,     bcc_name                            VARCHAR2 DEFAULT NULL
,     subject                             VARCHAR2
,     MESSAGE                             CLOB
,     priority                            PLS_INTEGER DEFAULT NULL
,     filename                            VARCHAR2 DEFAULT NULL
,     binaryfile                          BLOB DEFAULT EMPTY_BLOB ( )
,     DEBUG                               NUMBER DEFAULT 0 );
   v_parm_value                  VARCHAR2 ( 4000 );
   lbok                          BOOLEAN;
   v_smtp_server                 VARCHAR2 ( 50 );
   v_smtp_server_port            NUMBER := 25;
   crlf                          VARCHAR2 ( 10 ) := utl_tcp.crlf;
   conn                          utl_tcp.connection;
   p_debug_marker                PLS_INTEGER := 0;
   rc                            INTEGER;
   p_from_name                   VARCHAR2 ( 100 );
   p_to_name                     VARCHAR2 ( 4000 );
   p_cc_name                     VARCHAR2 ( 4000 );
   p_bcc_name                    VARCHAR2 ( 4000 );
   p_subject                     VARCHAR2 ( 150 );
   tx_timeout                    PLS_INTEGER := 240;
                                                  -- 240 Seconds (4 minutes);
   p_datestring                  VARCHAR2 ( 100 )
      :=    'Date: '
         || TO_CHAR ( SYSDATE, 'MM/DD/RR HH:MI AM' )
         || ' '
         || DBTIMEZONE
         || ' '
         || '(GMT'
         || DBTIMEZONE
         || ')';
   -- Customize the signature that will appear in the email's MIME header.
   -- Useful for versioning.
   mailer_id            CONSTANT VARCHAR2 ( 256 ) := 'Mailer by Oracle UTL_TCP';
   max_base64_line_width CONSTANT PLS_INTEGER := 76 / 4 * 3;
END;
CREATE OR REPLACE PACKAGE BODY mail_tools
IS
   PROCEDURE print_output (
      p_message                  IN       VARCHAR2 )
   IS
   BEGIN
      dbms_output.put_line ( SUBSTR ( p_message
,                                     1
,                                     250 ));
      IF LENGTH ( p_message ) > 250
      THEN
         dbms_output.put_line ( SUBSTR ( p_message
,                                        251
,                                        500 ));
      END IF;
      IF LENGTH ( p_message ) > 500
      THEN
         dbms_output.put_line ( SUBSTR ( p_message
,                                        501
,                                        750 ));
      END IF;
      IF LENGTH ( p_message ) > 750
      THEN
         dbms_output.put_line ( SUBSTR ( p_message
,                                        751
,                                        1000 ));
      END IF;
   EXCEPTION
      WHEN OTHERS
      THEN
         NULL;               -- Ignore errors... protect buffer overflow's etc.
   END print_output;
   FUNCTION dump_flatfile (
      p_query                    IN       VARCHAR2
,     p_dir                      IN       VARCHAR2
,     p_filename                 IN       VARCHAR2
,     p_separator                IN       VARCHAR2
,     p_headers                  IN       BOOLEAN DEFAULT FALSE
,     p_trailing_separator       IN       BOOLEAN DEFAULT FALSE
,     p_max_linesize             IN       NUMBER DEFAULT 32000
,     p_mode                     IN       VARCHAR2 DEFAULT 'w' )
      RETURN NUMBER
   IS
      l_output                      utl_file.file_type;
      l_thecursor                   INTEGER DEFAULT dbms_sql.open_cursor;
      l_columnvalue                 VARCHAR2 ( 4000 );
      l_status                      INTEGER;
      l_colcnt                      NUMBER DEFAULT 0;
      l_cnt                         NUMBER DEFAULT 0;
      l_separator                   VARCHAR2 ( 10 ) DEFAULT '';
      l_line                        LONG;
      l_desctbl                     dbms_sql.desc_tab;
      v_sqlerrm                     VARCHAR2 ( 32000 );
      l_mode                        CHAR ( 1 ) := 'w';
   BEGIN
      IF p_mode NOT IN ( 'w', 'a' )
      THEN
         l_mode := 'w';
      ELSE
         l_mode := p_mode;
      END IF;
      l_output := utl_file.fopen ( p_dir
,                                  p_filename
,                                  l_mode
,                                  p_max_linesize );
      dbms_sql.parse ( l_thecursor
,                      p_query
,                      dbms_sql.native );
      dbms_sql.describe_columns ( l_thecursor
,                                 l_colcnt
,                                 l_desctbl );
      FOR i IN 1 .. l_colcnt
      LOOP
         dbms_sql.define_column ( l_thecursor
,                                 i
,                                 l_columnvalue
,                                 4000 );
         IF ( l_desctbl ( i ).col_type = 2 )                   /* number type */
         THEN
            l_desctbl ( i ).col_max_len := l_desctbl ( i ).col_precision + 2;
         ELSIF ( l_desctbl ( i ).col_type = 12 )                 /* date type */
         THEN
/* length of my date format */
            l_desctbl ( i ).col_max_len := 20;
         ELSIF ( l_desctbl ( i ).col_type = 8 )                  /* LONG type */
         THEN
            l_desctbl ( i ).col_max_len := 2000;
         END IF;
         IF p_headers
         THEN
            utl_file.put ( l_output, l_separator || l_desctbl ( i ).col_name );
            l_separator := p_separator;
         END IF;
      END LOOP;
      IF p_trailing_separator
      THEN
         utl_file.put ( l_output, l_separator );
      END IF;
      IF p_headers
      THEN
         utl_file.new_line ( l_output );
      END IF;
      l_status := dbms_sql.EXECUTE ( l_thecursor );
      LOOP
         EXIT WHEN ( dbms_sql.fetch_rows ( l_thecursor ) <= 0 );
         l_line := NULL;
         l_separator := '';
         FOR i IN 1 .. l_colcnt
         LOOP
            dbms_sql.COLUMN_VALUE ( l_thecursor
,                                   i
,                                   l_columnvalue );
            IF NVL ( INSTR ( l_columnvalue, ',' ), 0 ) = 0
            THEN
               NULL;
            ELSE
               l_columnvalue := '"' || l_columnvalue || '"';
            END IF;
            utl_file.put ( l_output, l_separator || l_columnvalue );
            l_separator := p_separator;
         END LOOP;
         IF p_trailing_separator
         THEN
            utl_file.put ( l_output, l_separator );
         END IF;
         utl_file.new_line ( l_output );
         l_cnt := l_cnt + 1;
      END LOOP;
      dbms_sql.close_cursor ( l_thecursor );
      utl_file.fclose ( l_output );
      RETURN l_cnt;
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         dbms_output.put_line ( 'NO_DATA_FOUND' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.invalid_path
      THEN
         dbms_output.put_line ( 'UTL_FILE.INVALID_PATH' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.read_error
      THEN
         dbms_output.put_line ( 'UTL_FILE.READ_ERROR' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.write_error
      THEN
         dbms_output.put_line ( 'UTL_FILE.WRITE_ERROR' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.invalid_mode
      THEN
         dbms_output.put_line ( 'UTL_FILE.INVALID_MODE' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.invalid_filehandle
      THEN
         dbms_output.put_line ( 'UTL_FILE.INVALID_FILEHANDLE' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.invalid_operation
      THEN
         dbms_output.put_line ( 'UTL_FILE.INVALID_OPERATION' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.internal_error
      THEN
         dbms_output.put_line ( 'UTL_FILE.INTERNAL_ERROR' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN utl_file.invalid_maxlinesize
      THEN
         dbms_output.put_line ( 'UTL_FILE.INVALID_MAXLINESIZE' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN VALUE_ERROR
      THEN
         dbms_output.put_line ( 'UTL_FILE.VALUE_ERROR' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
      WHEN OTHERS
      THEN
         hum_do.default_exception ( 'ERROR in dump_csv : ' );
         utl_file.fclose ( l_output );
         RETURN l_cnt;
   END dump_flatfile;
   -- Return the next email address in the list of email addresses, separated
   -- by either a "," or a ";".  The format of mailbox may be in one of these:
   --   someone@some-domain
   --   "Someone at some domain" <someone@some-domain>
   --   Someone at some domain <someone@some-domain>
   FUNCTION get_mail_address (
      addr_list                  IN OUT   VARCHAR2 )
      RETURN VARCHAR2
   IS
      addr                          VARCHAR2 ( 256 );
      i                             PLS_INTEGER;
      FUNCTION lookup_unquoted_char (
         str                        IN       VARCHAR2
,        chrs                       IN       VARCHAR2 )
         RETURN PLS_INTEGER
      AS
         c                             VARCHAR2 ( 5 );
         i                             PLS_INTEGER;
         len                           PLS_INTEGER;
         inside_quote                  BOOLEAN;
      BEGIN
         inside_quote := FALSE;
         i := 1;
         len := LENGTH ( str );
         WHILE ( i <= len )
         LOOP
            c := SUBSTR ( str
,                         i
,                         1 );
            IF ( inside_quote )
            THEN
               IF ( c = '"' )
               THEN
                  inside_quote := FALSE;
               ELSIF ( c = '\' )
               THEN
                  i := i + 1;
               -- Skip the quote character
               END IF;
               GOTO next_char;
            END IF;
            IF ( c = '"' )
            THEN
               inside_quote := TRUE;
               GOTO next_char;
            END IF;
            IF ( INSTR ( chrs, c ) >= 1 )
            THEN
               RETURN i;
            END IF;
            <<next_char>>
            i := i + 1;
         END LOOP;
         RETURN 0;
      END;
   BEGIN
      addr_list := LTRIM ( addr_list );
      i := lookup_unquoted_char ( addr_list, ',;' );
      IF ( i >= 1 )
      THEN
         addr := SUBSTR ( addr_list
,                         1
,                         i - 1 );
         addr_list := SUBSTR ( addr_list, i + 1 );
      ELSE
         addr := addr_list;
         addr_list := '';
      END IF;
      i := lookup_unquoted_char ( addr, '<' );
      IF ( i >= 1 )
      THEN
         addr := SUBSTR ( addr, i + 1 );
         i := INSTR ( addr, '>' );
         IF ( i >= 1 )
         THEN
            addr := SUBSTR ( addr
,                            1
,                            i - 1 );
         END IF;
      END IF;
      RETURN addr;
   END;
   FUNCTION smtp_command (
      command                    IN       VARCHAR2
,     ok                         IN       VARCHAR2 DEFAULT '250'
,     code                       OUT      VARCHAR2
,     DEBUG                               NUMBER DEFAULT 0 )
      RETURN BOOLEAN
   IS
      response                      VARCHAR2 ( 3 );
      p_output_message              VARCHAR2 ( 255 );
      len                           PLS_INTEGER;
      PRAGMA AUTONOMOUS_TRANSACTION;
   BEGIN
      len := utl_tcp.write_line ( conn, command );
      p_output_message := SUBSTR ( utl_tcp.get_line ( conn, TRUE )
,                                  1
,                                  255 );
      response := SUBSTR ( p_output_message
,                          1
,                          3 );
      p_output_message :=
                         SUBSTR ( command || ' - ' || p_output_message
,                                 1
,                                 255 );
      IF DEBUG = 1
      THEN                                                          -- No Output
         NULL;
      ELSE                                          -- Then DBMS_OUTPUT messages
         print_output ( p_output_message );
      END IF;
      IF ( response <> ok )
      THEN
         code := response;
         RETURN FALSE;
      ELSE
         code := response;
         RETURN TRUE;
      END IF;
   EXCEPTION
      WHEN OTHERS
      THEN
         p_output_message := SQLCODE || ' - ' || SQLERRM;
         code := p_output_message;
         RETURN FALSE;
   END smtp_command;
   FUNCTION query_server (
      smtp_server                         VARCHAR2
,     smtp_server_port                    PLS_INTEGER DEFAULT 25
,     DEBUG                               NUMBER DEFAULT 0 )
      RETURN BOOLEAN
   IS
      p_output_message              VARCHAR2 ( 255 );
      PRAGMA AUTONOMOUS_TRANSACTION;
      err_noop                      EXCEPTION;    -- SMTP code 250 not received
      err_server_reject             EXCEPTION;
   -- SMTP code 421 means rejected
   BEGIN
      v_smtp_server := smtp_server;
      v_smtp_server_port := smtp_server_port;
-- Open the SMTP connection ...
      conn :=
         utl_tcp.open_connection ( remote_host =>                   v_smtp_server
,                                  remote_port =>                   v_smtp_server_port
,                                  tx_timeout =>                    tx_timeout );
      ----- OPEN SMTP PORT CONNECTION
      rc := utl_tcp.write_line ( conn, 'HELO ' || v_smtp_server );
            -- This will return a 250 OK response if your connection is valid
-- Initial handshaking ...
      ----- PERFORMS HANDSHAKING WITH SMTP SERVER
      p_output_message := utl_tcp.get_line ( conn, TRUE );
      IF DEBUG = 1
      THEN                                                          -- No Output
         NULL;
      ELSE                                          -- Then DBMS_OUTPUT messages
         print_output ( p_output_message );
      END IF;
      IF SUBSTR ( p_output_message
,                 1
,                 3 ) = '421'
      THEN
         RAISE err_server_reject;
      END IF;
      -- NOOP THE SERVER
      rc := utl_tcp.write_line ( conn, 'NOOP' );
            -- This will return a 250 OK response if your connection is valid
-- Initial handshaking ...
      ----- PERFORMS NOOP WITH SMTP SERVER
      p_output_message := utl_tcp.get_line ( conn, TRUE );
      IF DEBUG = 1
      THEN                                                          -- No Output
         NULL;
      ELSE                                          -- Then DBMS_OUTPUT messages
         print_output ( p_output_message );
      END IF;
      IF SUBSTR ( p_output_message
,                 1
,                 3 ) <> '250'
      THEN
         RAISE err_noop;
      END IF;
      rc := utl_tcp.write_line ( conn, 'QUIT' );
      ----- ENDS EMAIL TRANSACTION
      BEGIN
         FOR i_idx IN 1 .. 100
         LOOP
            p_output_message := utl_tcp.get_line ( conn, TRUE );
            IF DEBUG = 1
            THEN                                                   -- No Output
               NULL;
            ELSE                                    -- Then DBMS_OUTPUT messages
               print_output ( p_output_message );
            END IF;
         END LOOP;
      EXCEPTION
         WHEN OTHERS
         THEN
            IF DEBUG = 1
            THEN                                                   -- No Output
               NULL;
            ELSE                                    -- Then DBMS_OUTPUT messages
               print_output ( p_output_message );
            END IF;
      END;
      utl_tcp.close_connection ( conn );        ----- CLOSE SMTP PORT CONNECTION
      RETURN TRUE;
   EXCEPTION
      WHEN err_server_reject
      THEN
         print_output (    'ERROR -'
                        || ' Server Rejected Connection ::'
                        || ' SERVER_MSG := '
                        || p_output_message );
         RETURN FALSE;
      WHEN err_noop
      THEN
         print_output (    'ERROR -'
                        || ' NOOP Check Failed ::'
                        || ' SERVER_MSG := '
                        || p_output_message );
         utl_tcp.close_connection ( conn );     ----- CLOSE SMTP PORT CONNECTION
         RETURN FALSE;
   END query_server;
   FUNCTION get_local_binary_data (
      p_dir                      IN       VARCHAR2
,     p_file                     IN       VARCHAR2 )
      RETURN BLOB
   IS
      l_bfile                       BFILE;
      l_data                        BLOB;
      l_dbdir                       VARCHAR2 ( 100 ) := p_dir;
   BEGIN
      dbms_lob.createtemporary ( lob_loc =>                       l_data
,                                CACHE =>                         TRUE
,                                dur =>                           dbms_lob.CALL );
      l_bfile := BFILENAME ( l_dbdir, p_file );
      dbms_lob.fileopen ( l_bfile, dbms_lob.file_readonly );
      dbms_lob.loadfromfile ( l_data
,                             l_bfile
,                             dbms_lob.getlength ( l_bfile ));
      dbms_lob.fileclose ( l_bfile );
      RETURN l_data;
   EXCEPTION
      WHEN OTHERS
      THEN
         print_output (    'Error during GET_LOCAL_BINARY_DATA :: '
                        || SQLCODE
                        || ' - '
                        || SQLERRM );
         dbms_lob.fileclose ( l_bfile );
         RAISE;
   END get_local_binary_data;
   PROCEDURE attach_base64 (
      conn                       IN OUT NOCOPY utl_tcp.connection
,     DATA                       IN       BLOB )
   IS
      i                             PLS_INTEGER;
      len                           PLS_INTEGER;
      l_result                      PLS_INTEGER;
      l_buffer                      RAW ( 32767 );
      l_pos                         INTEGER := 1;
      l_blob_len                    INTEGER;
      l_amount                      BINARY_INTEGER := 32767;
      req                           utl_http.req;
      resp                          utl_http.resp;
      pdata                         RAW ( 200 );
   BEGIN
      -- Split the Base64-encoded attachment into multiple lines
      -- In writing Base-64 encoded text following the MIME format below,
      -- the MIME format requires that a long piece of data must be splitted
      -- into multiple lines and each line of encoded data cannot exceed
      -- 80 characters, including the new-line characters. Also, when
      -- splitting the original data into pieces, the length of each chunk
      -- of data before encoding must be a multiple of 3, except for the
      -- last chunk. The constant MAX_BASE64_LINE_WIDTH
      -- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
      -- of data before encoding.
      l_blob_len := dbms_lob.getlength ( DATA );
      WHILE l_pos < l_blob_len
      LOOP
         l_amount := max_base64_line_width;
         dbms_lob.READ ( DATA
,                        l_amount
,                        l_pos
,                        l_buffer );
         rc := utl_tcp.write_raw ( conn, utl_encode.base64_encode ( l_buffer ));
         utl_tcp.FLUSH ( conn );
         l_pos := l_pos + max_base64_line_width;
         rc := utl_tcp.write_line ( conn, crlf );
      END LOOP;
   END attach_base64;
   PROCEDURE sendmail (
      smtp_server                         VARCHAR2
,     smtp_server_port                    PLS_INTEGER DEFAULT 25
,     from_name                           VARCHAR2
,     to_name                             VARCHAR2
,     cc_name                             VARCHAR2 DEFAULT NULL
,     bcc_name                            VARCHAR2 DEFAULT NULL
,     subject                             VARCHAR2
,     MESSAGE                             CLOB
,     priority                            PLS_INTEGER DEFAULT NULL
,     filename                            VARCHAR2 DEFAULT NULL
,     binaryfile                          BLOB DEFAULT EMPTY_BLOB ( )
,     DEBUG                               NUMBER DEFAULT 0 )
   IS
      pos                           PLS_INTEGER := 1;
      bytes_o_data         CONSTANT PLS_INTEGER := 32767;
      offset                        PLS_INTEGER := bytes_o_data;
      msg_length           CONSTANT PLS_INTEGER
                                              := dbms_lob.getlength ( MESSAGE );
      v_line                        VARCHAR2 ( 32767 );
      i                             BINARY_INTEGER;
      v_slash_pos                   NUMBER;
      my_recipients                 VARCHAR2 ( 32767 );
      p_recipient_count             PLS_INTEGER := 0;
      p_output_message              VARCHAR2 ( 2000 );
      PRAGMA AUTONOMOUS_TRANSACTION;
      err_server_reject             EXCEPTION;
      -- SMTP code 421 means rejected
      err_message_send              EXCEPTION;         -- SMTP code must be 250
      err_end_of_input              EXCEPTION;
   -- Used to signify last line of input retrieved
      l_result                      PLS_INTEGER;
      l_buffer_b                    RAW ( 32767 );
      l_amount                      BINARY_INTEGER := 32767;
      l_pos                         INTEGER := 1;
      l_blob_len                    INTEGER;
      l_blob                        BLOB;
      g_debug                       BOOLEAN := TRUE;
      i_base64                      PLS_INTEGER;
      len_base64                    PLS_INTEGER;
   BEGIN
      v_smtp_server := smtp_server;
      v_smtp_server_port := smtp_server_port;
      l_blob := binaryfile;
-- Open the SMTP connection ...
      conn :=
         utl_tcp.open_connection ( remote_host =>                   v_smtp_server
,                                  remote_port =>                   v_smtp_server_port
,                                  tx_timeout =>                    tx_timeout );
      ----- OPEN SMTP PORT CONNECTION
      rc := utl_tcp.write_line ( conn, 'HELO ' || v_smtp_server );
-- Initial handshaking ...
      ----- PERFORMS HANDSHAKING WITH SMTP SERVER
      p_output_message := utl_tcp.get_line ( conn, TRUE );
      IF DEBUG = 1
      THEN                                                          -- No Output
         NULL;
      ELSE                                          -- Then DBMS_OUTPUT messages
         print_output ( p_output_message );
      END IF;
      IF SUBSTR ( p_output_message
,                 1
,                 3 ) = '421'
      THEN
         RAISE err_server_reject;
      ELSE
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
         rc := utl_tcp.write_line ( conn, 'MAIL FROM: ' || from_name );
         ----- MBOX SENDING THE EMAIL
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         IF DEBUG = 1
         THEN                                                      -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
         --      rc := UTL_TCP.write_line (conn, 'RCPT TO: ' || to_name);
         -- Specify recipient(s) of the email.
         my_recipients := to_name;
         WHILE ( my_recipients IS NOT NULL )
         LOOP
            BEGIN
               rc :=
                  utl_tcp.write_line ( conn
,                                         'RCPT TO: '
                                       || get_mail_address ( my_recipients ));
               p_recipient_count := p_recipient_count + 1;
            END;
         END LOOP;
--         DBMS_OUTPUT.put_line ('RCPT TO: COUNT ' || p_recipient_count);
         ----- MBOX RECV THE EMAIL
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         IF DEBUG = 1
         THEN                                                       -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
         --      rc := UTL_TCP.write_line (conn, 'RCPT TO: ' || cc_name);
         -- Specify cc recipient(s) of the email.
         my_recipients := cc_name;
         WHILE ( my_recipients IS NOT NULL )
         LOOP
            BEGIN
               rc :=
                  utl_tcp.write_line ( conn
,                                         'RCPT TO: '
                                       || get_mail_address ( my_recipients ));
               p_recipient_count := p_recipient_count + 1;
            END;
         END LOOP;
--         DBMS_OUTPUT.put_line ('RCPT TO: COUNT ' || p_recipient_count);
         ----- MBOX RECV THE EMAIL
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         IF DEBUG = 1
         THEN                                                       -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
         --      rc := UTL_TCP.write_line (conn, 'RCPT TO: ' || bcc_name);
         -- Specify bcc recipient(s) of the email.
         my_recipients := bcc_name;
         WHILE ( my_recipients IS NOT NULL )
         LOOP
            BEGIN
               rc :=
                  utl_tcp.write_line ( conn
,                                         'RCPT TO: '
                                       || get_mail_address ( my_recipients ));
               p_recipient_count := p_recipient_count + 1;
            END;
         END LOOP;
--         DBMS_OUTPUT.put_line ('RCPT TO: COUNT ' || p_recipient_count);
         ----- MBOX RECV THE EMAIL
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         IF DEBUG = 1
         THEN                                                       -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
         rc := utl_tcp.write_line ( conn, 'DATA' );
         ----- EMAIL MSG BODY START
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         IF DEBUG = 1
         THEN                                                       -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
-- build the start of the mail message ...
         rc := utl_tcp.write_line ( conn, p_datestring );
         rc := utl_tcp.write_line ( conn, 'From: ' || from_name );
         rc := utl_tcp.write_line ( conn, 'Subject: ' || subject );
         rc := utl_tcp.write_line ( conn, 'To: ' || to_name );
         IF cc_name IS NOT NULL
         THEN
            rc := utl_tcp.write_line ( conn, 'Cc: ' || cc_name );
         END IF;
         IF bcc_name IS NOT NULL
         THEN
            rc := utl_tcp.write_line ( conn, 'Bcc: ' || bcc_name );
         END IF;
         rc := utl_tcp.write_line ( conn, 'Mime-Version: 1.0' );
              -- Set priority:
         --   High      Normal       Low
         --   1     2     3     4     5
         IF ( priority IS NOT NULL )
         THEN
            rc := utl_tcp.write_line ( conn, 'X-Priority: ' || priority );
         END IF;
         rc := utl_tcp.write_line ( conn, 'X-Mailer: ' || mailer_id );
         rc :=
            utl_tcp.write_line
               ( conn
,                'Content-Type: multipart/mixed; boundary="=_mixed 0052287A85256E75_="' );
         rc := utl_tcp.write_line ( conn, '' );
         rc :=
            utl_tcp.write_line
               ( conn
,                'This is a Mime message, which your current mail reader may not' );
         rc :=
            utl_tcp.write_line
               ( conn
,                'understand. Parts of the message will appear as text. If the remainder' );
         rc :=
            utl_tcp.write_line
               ( conn
,                'appears as random characters in the message body, instead of as' );
         rc :=
            utl_tcp.write_line
               ( conn
,                'attachments, then you''ll have to extract these parts and decode them' );
         rc := utl_tcp.write_line ( conn, 'manually.' );
         rc := utl_tcp.write_line ( conn, '' );
         rc := utl_tcp.write_line ( conn, '--=_mixed 0052287A85256E75_=' );
         rc :=
            utl_tcp.write_line ( conn
,                                'Content-Type: text/html; charset=8859-1' );
         rc := utl_tcp.write_line ( conn, '' );
         rc := utl_tcp.write_line ( conn, '<html>' );
         rc := utl_tcp.write_line ( conn, '<head>' );
         rc :=
            utl_tcp.write_line
               ( conn
,                '<meta http-equiv="Content-Type" content="text/html;charset=8859-1">' );
         rc := utl_tcp.write_line ( conn, '<title>' );
         rc := utl_tcp.write_line ( conn, subject );
         rc := utl_tcp.write_line ( conn, '</title>' );
         rc := utl_tcp.write_line ( conn, '</head>' );
         rc := utl_tcp.write_line ( conn, '<body>' );
         WHILE pos < msg_length
         LOOP
            rc :=
               utl_tcp.write_line ( conn
,                                   dbms_lob.SUBSTR ( MESSAGE
,                                                     offset
,                                                     pos ));
            pos := pos + offset;
            offset := LEAST ( bytes_o_data, msg_length - offset );
         END LOOP;
         rc := utl_tcp.write_line ( conn, '<BR><BR>' );
         rc := utl_tcp.write_line ( conn, '</body></html>' );
         rc := utl_tcp.write_line ( conn, '' );
         rc := utl_tcp.write_line ( conn, crlf );
-- Append the file BLOB  ...
            -- If the filename has been supplied ... it will fail if the BLOB is empty
         IF filename IS NOT NULL
         THEN
            BEGIN
               -- generate the MIME boundary line ...
               rc :=
                    utl_tcp.write_line ( conn, '--=_mixed 0052287A85256E75_=' );
               rc :=
                  utl_tcp.write_line
                          ( conn
,                              'Content-Type: application/octet-stream; name="'
                            || filename
                            || '"' );
               rc :=
                  utl_tcp.write_line
                              ( conn
,                                  'Content-Disposition: attachment; filename="'
                                || filename
                                || '"' );
               rc :=
                  utl_tcp.write_line ( conn
,                                      'Content-Transfer-Encoding: base64' );
               rc := utl_tcp.write_line ( conn, '' );
               rc := utl_tcp.write_line ( conn, '' );
               -- and append the file contents to the end of the message ...
               -- Go get the file and the loop through blob and attach data
               -- and append the file contents to the end of the message ...
               attach_base64 ( conn =>                          conn
,                              DATA =>                          l_blob );
            EXCEPTION
               WHEN OTHERS
               THEN
                  p_output_message :=
                        'Error in attaching file '
                     || filename
                     || ' :: '
                     || SQLCODE
                     || ' - '
                     || SQLERRM;
                  IF DEBUG = 1
                  THEN                                              -- No Output
                     NULL;
                  ELSE                              -- Then DBMS_OUTPUT messages
                     print_output ( p_output_message );
                  END IF;
                  RAISE err_message_send;
            END;
         END IF;
         rc := utl_tcp.write_line ( conn, '' );
         -- append the final boundary line ...
         rc := utl_tcp.write_line ( conn, '' );
         rc := utl_tcp.write_line ( conn, '--=_mixed 0052287A85256E75_=--' );
         rc := utl_tcp.write_line ( conn, '' );
         -- and close the SMTP connection  ...
         rc := utl_tcp.write_line ( conn, '.' );
         ----- EMAIL MESSAGE BODY END
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         IF DEBUG = 1
         THEN                                                       -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
--      DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
         rc := utl_tcp.write_line ( conn, 'QUIT' );
         ----- ENDS EMAIL TRANSACTION
         p_output_message := utl_tcp.get_line ( conn, TRUE );
         -- Capture '.' Message sent dialog
         IF DEBUG = 1
         THEN                                                       -- No Output
            NULL;
         ELSE                                       -- Then DBMS_OUTPUT messages
            print_output ( p_output_message );
         END IF;
         BEGIN
            FOR i_idx IN 1 .. 100
            LOOP
               p_output_message := utl_tcp.get_line ( conn, TRUE );
               IF DEBUG = 1
               THEN                                                -- No Output
                  NULL;
               ELSE                                 -- Then DBMS_OUTPUT messages
                  print_output ( p_output_message );
               END IF;
            END LOOP;
         EXCEPTION
            WHEN OTHERS
            THEN
               IF DEBUG = 1
               THEN                                                -- No Output
                  NULL;
               ELSE                                 -- Then DBMS_OUTPUT messages
                  print_output ( p_output_message );
               END IF;
         END;
      END IF;                                               -- err_server_reject
      utl_tcp.close_connection ( conn );        ----- CLOSE SMTP PORT CONNECTION
   EXCEPTION
      WHEN err_message_send
      THEN
         print_output (    CHR ( 10 )
                        || CHR ( 10 )
                        || 'ERROR -'
                        || ' Message was not submitted for delivery' );
         print_output ( ' [FROM_NAME := ' || from_name || '] ' );
         print_output ( ' [TO_NAME := ' || to_name || '] ' );
         print_output ( ' [CC_NAME := ' || cc_name || '] ' );
         print_output ( ' [BCC_NAME := ' || bcc_name || '] ' );
         print_output ( ' [SUBJECT := ' || subject || '] ' );
         print_output ( ' SERVER_MSG := ' || p_output_message );
         utl_tcp.close_connection ( conn );     ----- CLOSE SMTP PORT CONNECTION
      WHEN err_server_reject
      THEN
         print_output (    CHR ( 10 )
                        || CHR ( 10 )
                        || 'ERROR -'
                        || ' Server Rejected Email' );
         print_output ( ' [FROM_NAME := ' || from_name || '] ' );
         print_output ( ' [TO_NAME := ' || to_name || '] ' );
         print_output ( ' [CC_NAME := ' || cc_name || '] ' );
         print_output ( ' [BCC_NAME := ' || bcc_name || '] ' );
         print_output ( ' [SUBJECT := ' || subject || '] ' );
         print_output ( ' SERVER_MSG := ' || p_output_message );
      WHEN OTHERS
      THEN
         print_output (    CHR ( 10 )
                        || CHR ( 10 )
                        || 'ERROR :: '
                        || SQLCODE
                        || ' - '
                        || SQLERRM );
         print_output ( ' [FROM_NAME := ' || from_name || '] ' );
         print_output ( ' [TO_NAME := ' || to_name || '] ' );
         print_output ( ' [CC_NAME := ' || cc_name || '] ' );
         print_output ( ' [BCC_NAME := ' || bcc_name || '] ' );
         print_output ( ' [SUBJECT := ' || subject || '] ' );
         print_output ( ' SERVER_MSG := ' || p_output_message );
   END sendmail;
END;
/

Perhaps your new SMTP server requires a more secure form of authentication than AUTH LOGIN. If you telnet to this new SMTP server on port 25 you should be issue the HELO or EHLO command to find out what AUTH mechanisms the server supports. You could then alter your code to use one of the supported authentication mechanisms.

Similar Messages

  • Java.lang.NoSuchMethodError: com.sun.mail.util.SocketFetcher.getSocket

    I am recieving the above error in a FileNet Content Manager environment. The full stack trace is:
    Exception in thread "main" java.lang.NoSuchMethodError: com.sun.mail.util.SocketFetcher.getSocket(Ljava/lang/String;ILjava/util/Properties;Ljava/lang/String;Z)Ljava/net/Socket;
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1195)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:322)
    at javax.mail.Service.connect(Service.java:233)
    at javax.mail.Service.connect(Service.java:134)
    at javax.mail.Service.connect(Service.java:86)
    at javax.mail.Transport.send0(Transport.java:162)
    at javax.mail.Transport.send(Transport.java:80)
    at com.bearingpoint.utilities.EMail.send(EMail.java:171)
    at com.bearingpoint.utilities.EMail.send(EMail.java:31)
    at email.main(email.java:11)
    I have spent many hours, fiddling with classpaths, ensuring that the mail.jar, mailapi.jar, smtp.jar, activation.jar are all from the same generation of JavaMail. With my classpath set correctly I can run a simple program constructed to just test whether the box can send out email from the command line.
    The code for the program is:
    public class email {
         public email() {
         public static void main (String args[]) {
              try {
              EMail.send("10.132.147.62", "[email protected]", "[email protected]", "test", "test");
              catch (Exception e) {
                   System.err.println(e.toString());
    Where EMail.send() is:
    public static void send(
    String mail_server_host,
    String email_from,
    String email_to,
    String subject,
    String message) throws AddressException, MessagingException, IOException {
    send(mail_server_host,
    (Authenticator)null,
    new InternetAddress[] {new InternetAddress(email_from)},
    new InternetAddress[] {new InternetAddress(email_to)},
    (InternetAddress[])null,
    (InternetAddress[])null,
    subject,
    message,
    null,
    null);
    which calls:
    public static void send(
    String mail_server_host,
    Authenticator authenticator,
    InternetAddress[] addresses_from,
    InternetAddress[] addresses_to,
    InternetAddress[] addresses_cc,
    InternetAddress[] addresses_bcc,
    String subject,
    String message,
    InputStream[] attachments,
    MimeType[] attachmentTypes) throws MessagingException,IOException {
    Properties properties = new Properties();
    properties.put("mail.smtp.host", mail_server_host);
    MimeMessage msg = new MimeMessage(
    Session.getInstance(properties, authenticator));
    msg.addFrom(addresses_from);
    msg.setRecipients(Message.RecipientType.TO, addresses_to);
    msg.setRecipients(Message.RecipientType.CC, addresses_cc);
    msg.setRecipients(Message.RecipientType.BCC, addresses_bcc);
    msg.setSubject(subject);
    BodyPart bpBody = new MimeBodyPart();
    bpBody.setText(message);
    Multipart mpMessageBody = new MimeMultipart();
    if (attachments == null && attachmentTypes == null) {
    mpMessageBody.addBodyPart(bpBody);
    msg.setContent(mpMessageBody);
    else if (attachments == null) {
    bpBody.setContent(message, attachmentTypes[0].toString());
    mpMessageBody.addBodyPart(bpBody);
    msg.setContent(mpMessageBody);
    else {
    mpMessageBody.addBodyPart(bpBody);
    for (int i=0; i<attachments.length;i++) {
    bpBody = new MimeBodyPart();
    DataSource dsAttachment = new ByteArrayDataSource(attachments, attachmentTypes[i].toString());
    bpBody.setDataHandler(new DataHandler(dsAttachment));
    bpBody.setFileName("attachment." + new MimeFileExtensions(attachmentTypes[i].getValue()).toString());
    mpMessageBody.addBodyPart(bpBody);
    msg.setContent(mpMessageBody);
    Transport.send(msg);
    As said before all .jar files are of the same generation, yet when I run FileNet and the underlying content engine, and try to send an email, I recieve this exception. I have run out of ideas, and any help would be appreciated.
    Things I've tried (multiple times):
    - Removing any old versions of the jar files and replace them with JavaMail 1.3.3_01
    - Have the content engine specifically import the JavaMail jar files.
    While I realize some of you may not know what FileNet is, perhaps you have come across this exception before. Any new ideas would be more then appreciated.
    Thank you for your time.

    I haven't seen this error before so I need more detail to reproduce it.
    It looks like you daisy chained calls to various static send() methods from various classes. Could you write a static main() for the class with the send() method actually doing the work? In the main() write the test case and compile it, test it and if it still doesnt work post it. Please include the import statements as it is germain to the solution.
    Its much easier for me to help you if I don't have to recreate "FileNet" to reproduce your error.
    As an alternative....
    The following code I got from: http://javaalmanac.com/egs/javax.mail/SendApp.html?l=new
    its simpler than you're code but gets the job done (without attachments).
    I've tested it and it works with:
    javac -classpath .;c:\sun\appserver\lib\j2ee.jar;c:\sun\appserver\lib\mail.jar SendApp.java
    java -classpath .;c:\sun\appserver\lib\j2ee.jar;c:\sun\appserver\lib\mail.jar SendApp
    Ran on Windows XP, Sun J2EE 1.4/Appserver Bundle
        import java.io.*;
        import javax.mail.*;
        import javax.mail.internet.*;
        import javax.activation.*;
        public class SendApp {
            public static void send(String smtpHost, int smtpPort,
                                    String from, String to,
                                    String subject, String content)
                    throws AddressException, MessagingException {
                // Create a mail session
                java.util.Properties props = new java.util.Properties();
                props.put("mail.smtp.host", smtpHost);
                props.put("mail.smtp.port", ""+smtpPort);
                Session session = Session.getDefaultInstance(props, null);
                // Construct the message
                Message msg = new MimeMessage(session);
                msg.setFrom(new InternetAddress(from));
                msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
                msg.setSubject(subject);
                msg.setText(content);
                // Send the message
                Transport.send(msg);
            public static void main(String[] args) throws Exception {
                // Send a test message
                send("10.1.4.105", 25, "[email protected]", "[email protected]",
                     "test", "test message.");
        }

  • SQL Server Utility - How to Remove Instance that No Longer Exists on Server

    I had a default instance that I had installed for an application.  But then I was told they wanted it as a named instance.  I had added the default instance to the UCP (SQL Server Utility).  I have uninstalled the default instance forgetting
    that I had added it to the UCP.  Now when I try to remove the managed instance I get the following error:
    The action has failed.  Step failed.  The SQL Server connection does not correstpond to this managed instance object.  (Microsoft.Sqlserver.Management.Utility)
    How do I remove the managed instance from the UCP?  Do I need to go into a table in database sysutility_mdw and delete something?
    select * from msdb.dbo.sysutility_ucp_managed_instances
    where instance_id=57
    Maybe delete from table msdb.dbo.sysutility_ucp_managed_instances?
    Or maybe table sysutility_ucp_managed_instances_internal?
    lcerni

    I ran this
    EXEC msdb.dbo.sp_sysutility_ucp_remove_mi @instance_id=57
    And it fixed the issue.
    lcerni

  • Attach a digital signature to SQL mail

    How do I use an email certificate to sign email sent using SQL Mail? I have a certificate installed so that I can sign email sent from Outlook. This is on SQL Server 2005 using either Database Mail or SQL Mail.

    How do I use an email certificate to sign email sent using SQL Mail?
    Hello Jeffrey,
    It's not possible with SQL DB-Mail, you have to use an other (own developed) application to send signed e-mails.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • UCCX 7.01, fresh install - SQL Reuse Utility doesn't work

    I am installing a fresh copy on UCCX 7.0 on two 7845 servers. As per the uccx70ig, after installing UCCX, before reboot, you install SQL. I have an MS SQL 2K CD from 4.0(5a), I installed the SQL Reuse Utility (SQLUtilTool.exe, v2.0.3) in the appropriate directory. After the "disable CSA", etc messages, I quickly get a message that the SQL install failed, look at C:\WINNT\setup.log for messages.
    There is nothing in there to indicate the problem.
    Anyone had this issue before? Thanks.

    Thanks, Anthony. The ZIP file, v2.0.3 was downloaded and expanded into a C:\SQL2K directory as per the instructions. The C:\WINNT\setup.log file that the failure message pointed me to shows the following:
    [InstallShield Silent]
    Version=v5.00.000
    File=Log File
    [Status]
    Completed=2
    [ResponseResult]
    ResultCode=0
    The C:\SQL2KUTIL.LOG file (for the last run) shows:
    CSCO:Wed May 05 16:24:04 2010:Display_Start_Message()
    CSCO:Wed May 05 16:24:05 2010:Display_Start_Message() - nResult = 6
    CSCO:Wed May 05 16:24:05 2010:CheckInstalled()
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::openKey() opening key SOFTWARE\Cisco Systems\CRA\CurrentVersion
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::readValue() sValue=version
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::readValue() sData=7.0(1)_Build168
    CSCO:Wed May 05 16:24:05 2010:CheckCRSInstalled() returned =1
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted()
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted(), sDrive value =E:\
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted() returned =1
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted() returned =1
    CSCO:Wed May 05 16:24:05 2010:IsSql2KInstalled()
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::openKey() opening key SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft SQL Server 2000 (CRSSQL)
    CSCO:Wed May 05 16:24:05 2010:IsSql2KInstalled() - exception: csco_clss::Registry::openKey() RegOpenKeyEx failed {The system cannot find the file specified: 2}
    CSCO:Wed May 05 16:24:05 2010:IsSql2KInstalled() returned =0
    CSCO:Wed May 05 16:24:05 2010:Sql_Installation()
    CSCO:Wed May 05 16:24:05 2010:RegAdd()
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::createKey() creating key SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::addValue() type=4, value={ff25f0b5-c894-45f4-a29d-1bdd0c7926cd}, data=1
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::addValue() value added/updated successfully
    CSCO:Wed May 05 16:24:07 2010:StopNM()
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::openKey() opening key SOFTWARE\Cisco Systems\CRA\CurrentVersion
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::readValue() sValue=version
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::readValue() sData=7.0(1)_Build168
    CSCO:Wed May 05 16:24:07 2010:StopNM() in:s string from reg =7.0
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Service::Service() opening service Cisco Unified CCX Node Manager
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Service::StopServices() : Service is already stopped
    CSCO:Wed May 05 16:24:07 2010:StopNM() returned
    CSCO:Wed May 05 16:24:07 2010:LaunchSQL2K()
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Process::launch() about to launch E:\SQL2K\x86\setup\setupsql.exe -s -f1 C:\SQL2K\setupSQL2K.iss
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Process::initEnv(): Set 'PATH' to C:\Program Files\HP\NCU;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\wfavvid\lib;C:\Program Files\Cisco\bin;C:\Program Files\Cisco\AlarmService;C:\Program Files\Cisco\Desktop\bin;C:\Program Files\wfavvid\;
    CSCO:Wed May 05 16:24:12 2010:csco_clss::Process::launch() finished launching/waiting for process
    CSCO:Wed May 05 16:24:12 2010:LaunchSQL2K() returned successfully
    CSCO:Wed May 05 16:24:12 2010:LaunchSP4()
    CSCO:Wed May 05 16:24:12 2010:csco_clss::Process::launch() about to launch C:\SQL2K\MsSql2K.sp4\x86\setup\setupsql.exe -s -f1 C:\SQL2K\setupSP4.iss
    CSCO:Wed May 05 16:24:12 2010:csco_clss::Process::initEnv(): Set 'PATH' to C:\Program Files\HP\NCU;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\wfavvid\lib;C:\Program Files\Cisco\bin;C:\Program Files\Cisco\AlarmService;C:\Program Files\Cisco\Desktop\bin;C:\Program Files\wfavvid\;;
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Process::launch() finished launching/waiting for process
    CSCO:Wed May 05 16:24:17 2010:LaunchSP4() returned successfully
    CSCO:Wed May 05 16:24:17 2010:SetStartType()
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Service::Service() opening service mssearch
    CSCO:Wed May 05 16:24:17 2010:Exception in ServiceSetStarType()csco_clss::Service::Service() unable to open service. {The specified service does not exist as an installed service: 1060}
    CSCO:Wed May 05 16:24:17 2010:RegAddCiscoSQLflag()
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::createKey() creating key SOFTWARE\Cisco Systems\CRA\CurrentVersion
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::addValue() type=1, value=SQLProvider, data=cisco
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::addValue() value added/updated successfully
    CSCO:Wed May 05 16:24:17 2010:RegAddCiscoSQLflag() returned successfully
    CSCO:Wed May 05 16:24:17 2010:ReadMSSQL2KIssLogFile() in:sDirectory=C:\WINNTsLogFile=setup.log
    CSCO:Wed May 05 16:24:17 2010:ReadMSSQL2KIssLogFile() the sFilePath: C:\WINNT\setup.log
    CSCO:Wed May 05 16:24:17 2010:csco_clss::readMSSQL2KIssLogFile() the nResultCode: 0
    CSCO:Wed May 05 16:24:17 2010:csco_clss::readMSSQL2KIssLogFile() the nCompleted: 2
    CSCO:Wed May 05 16:24:17 2010:ReadMSSQL2KIssLogFile() found error in the Iss log file C:\WINNT\setup.log bError:1

  • Error while connecting to Microsoft Exchange server using javamail: "com.sun.mail.util.MailConnectException: Couldn't connect to host, port: host name , 993; timeout -1"

    I am trying to read mails from my outlook microsoft exchange server. Following is the code:
    public void readEmailsFromOutlook(/*String host, String username, String password*/ ) throws MessagingException, IOException {
          String host = "hostname";
          String username = "domain\\username";
          String password = "password"
          // Create empty properties
          Properties props = System.getProperties();
          props.setProperty("mail.smtp.auth","true");
          props.setProperty("mail.store.protocol","imaps");
          props.setProperty("mail.imap.auth.plain.disable","true");
          props.setProperty("mail.imap.host",host);
          props.setProperty("mail.imap.port","993");
          props.setProperty("mail.imap.user",username);
          props.setProperty("mail.imap.pwd",password);
          props.setProperty("mail.imap.debug","true");
          props.setProperty("mail.imap.ssl.protocols","SSL");
          props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.setProperty("mail.imap.socketFactory.fallback", "false");
          props.setProperty("mail.imap.socketFactory.port", "993");
          // Get session
                     Session session = Session.getInstance(props, new ExchangeAuthenticator(username, password));
          session.setDebug(true);
          // Get the store
          Store store = session.getStore("imaps");
          //Store store = session.getStore();
          store.connect(host, username, password);
          // Get folder
          Folder folder = store.getFolder("INBOX");
          folder.open(Folder.READ_ONLY);
          BufferedReader reader = new BufferedReader(new InputStreamReader(
              System.in));
          // Get directory
          Message message[] = folder.getMessages();
          for (int i = 0, n = message.length; i < n; i++) {
            System.out.println(i + ": " + message[i].getFrom()[0] + "\t"
                + message[i].getSubject());
            System.out.println("Read message? [YES to read/QUIT to end]");
            String line = reader.readLine();
            if ("YES".equalsIgnoreCase(line)) {
              System.out.println(message[i].getContent());
            } else if ("QUIT".equalsIgnoreCase(line)) {
              break;
          // Close connection
          folder.close(false);
          store.close();
    But it threw the following error:
    DEBUG: setDebug: JavaMail version 1.5.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle]
    DEBUG IMAPS: mail.imap.fetchsize: 16384
    DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
    DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
    DEBUG IMAPS: mail.imap.appendbuffersize: -1
    DEBUG IMAPS: mail.imap.minidletime: 10
    DEBUG IMAPS: trying to connect to host <hostname>,port 993, isSSL true
    com.sun.mail.util.MailConnectException: Couldn't connect to host, port: 10.75.250.60, 993; timeout -1;
      nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:693)
    at javax.mail.Service.connect(Service.java:345)
    at javax.mail.Service.connect(Service.java:226)
    at com.capgemini.utilities.Utilities.readEmailsFromOutlook(Utilities.java:1261)
    Whats wrong with my code?
    Please help!!!!

    You're using the "imaps" protocol, but you've set properties for the "imap" protocol.  Change all the property names from mail.imap.* to mail.imaps.*.
    Also, get rid of all the socket factory properties.
    If you still can't connect, see these connection debugging tips.
    Most likely you're using the wrong host name or port number.  In almost all cases, it's better to just let JavaMail choose the correct port number.

  • Using clob in sql loader utility in oracle 9i

    Hi,
    I want to load data into a table with 2 clob columns using a sql loader utility dat file and control file created programatically.
    The size of clob in dat file can change and the clob columns are inline in data file.
    As per 9i doc the size of clob is 4GB .
    How can I change the control file so that it can load max 4 GB data in clob columns .
    I am getting error while calling sqlldr using below control file :
    SQL*Loader-350: Syntax error at line 13.
    Expecting non-negative integer, found "-294967296".
    ,"NARRATIVE" char(4000000000)
    ^
    control file :
    LOAD DATA
    INFILE '' "str X'3C213E0A'"
    APPEND INTO TABLE PSD_TERM
    FIELDS TERMINATED BY '~^'
    TRAILING NULLCOLS
    "PSD_ID" CHAR(16) NULLIF ("PSD_ID"=BLANKS)
    ,"PSD_SERIAL_NUM" CHAR(4) NULLIF ("PSD_SERIAL_NUM"=BLANKS)
    ,"PSD_TERM_COD" CHAR(4) NULLIF ("PSD_TERM_COD"=BLANKS)
    ,"PSD_TERM_SER_NO" CHAR(4) NULLIF ("PSD_TERM_SER_NO"=BLANKS)
    ,"VERSION_DT" DATE "DD-MON-YYYY HH:MI:SS AM" NULLIF ("VERSION_DT"=BLANKS)
    ,"LATEST_VERSION" CHAR(1) NULLIF ("LATEST_VERSION"=BLANKS)
    ,"NARRATIVE" char(4000000000)
    ,"PARTITION_DT" DATE "DD-MON-YYYY HH:MI:SS AM" NULLIF ("PARTITION_DT"=BLANKS)
    ,"NARRATIVE_UNEXPANDED" char(4000000000)
    )

    Yes, you can do it. Create the sequence (suppose you call it "PK_SEQ_X") and then in your control file reference it as "PK_SEQ_X.NEXTVAL". For example suppose you wanted to put it into a column named 'Y' the entry in your control file will look like 'load data insert into table Z (Y "PK_SEQ_X.NEXTVAL", ....)'
    Note that the double quotes around the sequence name are required.

  • Load Data from SQL Server to Oracle 10g using Sql*loader utility

    I am trying to lod data from sql server 2005 to oracle 10g.
    What is the best way to do it?
    Can sql*loader utility do it?
    what is the difference of using sql*loader utility and migration tool fom sql developer ?
    Thanks
    Edited by: user11313758 on Sep 30, 2009 4:30 PM

    Hello:
    You could consider using Oracle Heterogeneous Services to do this. If your Oracle database is on a Windows platform the link below shows you how to make a connection to SqlServer from an Oracle database.
    http://www.databasejournal.com/features/oracle/article.php/3442661/Making-a-Connection-from-Oracle-to-SQL-Server.htm
    Varad

  • Sql mail

    how to configure sql mail  server 2008 for 64bit machine

    See Configure Database Mail; it's for 32 and 64 bit the same.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Use of Oracle pump utility as equivalence of SQL bcp utility??

    can anyone throw any pointers to how to use Oracle pump utility as equivalence of SQL bcp utility??

    The equivalence of BCP is SQL*Loader. Data pump is used for export/import. During an import operation it can read just a file created by data pump export.

  • Pls Help for Sql Loader utility

    Dear friends,
    I want to execute Sql Loader utility by procedure.
    Can anyone give me any idea about it.
    Thanks in adavance.

    Why?
    Why build a kludgy and unscalable application?
    Sybrand Bakker
    Senior Oracle DBA

  • Not able to sending the Mail using java mail utility

    Hi, I am new to java mail utility and written first time for sending mail. If any body an help me out in resolving the problem I would be thankful to him/her........below is the code which I m trying......
    package test;
    import javax.servlet.http.HttpServlet;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    /*import javax.mail.Address;
    import javax.mail.Authenticator;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.Message.RecipientType;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;*/
    * @author chauhasd
    * TODO To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Style - Code Templates
    public class SendMailServlet extends HttpServlet{
         public SendMailServlet(){
         public void sendMail(){
              java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              Properties props=new Properties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.host","pcsttc.patni.com");
              props.put("mail.smtp.port","25");
              props.put("mail.smtp.auth","true");
              props.put("mail.smtp.starttls.enable","true");
              Session session=Session.getDefaultInstance(props,new MyAuthenticator());
              session.setDebug(true);
              MimeMessage message=new MimeMessage(session);
              try{
                   message.setContent("Hello....","text/plain");
                   message.setSubject("Testing Mail");
                   Address strTo = new InternetAddress("[email protected]");
                   Address strFrom = new InternetAddress("[email protected]");
                   Address strReplyTO = new InternetAddress("[email protected]");
                   message.setFrom(strFrom);
                   message.setReplyTo(new Address[]{strReplyTO});
                   message.setRecipient(Message.RecipientType.TO,strTo);
                   Transport.send(message);
              }catch (AddressException e)
    //               TODO Auto-generated catch block
                   e.printStackTrace();
              }catch (NoSuchProviderException e){
    //               TODO Auto-generated catch block
                   e.printStackTrace();
              }catch (MessagingException e){
    //               TODO Auto-generated catch block
                   e.printStackTrace();
         protected PasswordAuthentication getPasswordAuthentication()
              return new PasswordAuthentication("[email protected]", "sid35789");
         public static void main(String [] args){
              new SendMailServlet().sendMail();
    ERROR :
    DEBUG: setDebug: JavaMail version 1.3.1
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth true
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
         class javax.mail.AuthenticationFailedException
         at javax.mail.Transport.send0(Transport.java:218)
         at javax.mail.Transport.send(Transport.java:80)
         at test.SendMailServlet.sendMail(SendMailServlet.java:59)
         at test.SendMailServlet.main(SendMailServlet.java:81)

    Sangyesh wrote:
    In my application,we already implemented it so we cant go for javamail.That does not make sense. Your 'implementation' does not work so you have not yet fully 'implemented' it. Using Javamail takes about 4 lines of code to do what you have done so far and it will work.
    Please suggest me regarding this,so that I can go ahead and resolve it.Use the Javamail API.

  • Viewing SQL mail attachment on Blackberry

    We receive many reports from SQL using SQL Mail sending to our Exchange account. On the BB these text file attachments are not viewable correctly. The report is columns (4) and text but on the BB they appear empty. There is a space or 2 but no viewable data.

    Hi portnh,
                      If you press " N " it will move from one date to another,and if the message is unread message you can try pressing  " U " it will take you to the unread message ,You may try pressing " S " it may open the search box where you can search your message.
                         Try all this but I think it will better if you get your trackpad repaired to avoid all this problems.
    Good Luck
    Prince
    Click " Like " if you want to Thank someone.
    If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.
    Click " Like " if you want to Thank someone.
    If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.

  • Not able to pass a date in send mail utility.

    Hi,
    The requirement is :
    when some one is getting terminated in HR, send a mail to a fixed set of people.
    I created a trigger on Insert. Passing the person_id and calling a conc program. The IN to the conc program is person id. Now in the pkg I am using a cursor to get some details and sending as a send mail. Using FND_Message.
    But when I am trying to pass the end_date as a part of the message it's not working. I gave fnd_log to check what is getting passed in that date, but it's always null. Not sure why.
    I even tried using to_char but does not help. Any clue?

    Shankzzz wrote:
    when some one is getting terminated in HR, send a mail to a fixed set of people.Yeah.. everyone in HR should be termimated - and we, Cyberdyne Systems, have the perfect solution. It is called the Cyberdyne Systems Model 101. Easy to program. Never yet have missed a target. And as we also do not like HR, we can sell you a Model 101 at a special dis-count too.
    I created a trigger on Insert. Passing the person_id and calling a conc program. The IN to the conc program is person id. Now in the pkg I am using a cursor to get some details and sending as a send mail. Using FND_Message.
    FND_MESSAGE ?
    But when I am trying to pass the end_date as a part of the message it's not working. I gave fnd_log to check what is getting passed in that date, but it's always null. Not sure why.
    FND_LOG ?
    No idea what these are. You are perhaps talking Oracle Applications?
    In this forum we talk SQL and PL/SQL server language - the plain vanilla flavour that comes with every Oracle RDBMS database. No applications. No Forms.
    I even tried using to_char but does not help. Any clue?Why would a to_char() change a null value into a non-null value?

  • Mail from Exchange 2010 mailbox - BCC to Hotmail addresses with blank To: field not hounoured

    Hi
    This feels related to a previous question
    http://social.technet.microsoft.com/Forums/exchange/en-US/bec88844-79c1-4d17-bf73-9425842b22de/problem-sending-mail-with-bcc-and-without-to?forum=exchangesvrgenerallegacy but is slightly different - it just applies to Hotmail and related addresses (e.g.
    hotmail.com, hotmail.co.uk, outlook.com, live.co.uk).
    Sending from our Exchange 2010 to BCC addresses with blank To: field, the BCC is not being honoured, but just by Hotmail-related addresses. Any Hotmail-related recipient sent to in this fashion sees all their and other Hotmail-related addresses in the To:
    field. But any other addresses to other mail hosts (gmail, yahoo etc) in the same BCC list aren't shown, and recipients at the other mail hosts have a fully hidden BCC list (i.e. see no To addresses at all).
    If the To: field has an address then there is no problem - all BCC addresses are hidden for all recipients as expected.
    It feels like it is the way the header is being handled by the Hotmail MTAs. But I only see this behaviour from our Exchange 2010 servers (including test servers).
    Below are message headers from examples - anyone any ideas on this?
    Thanks,
    Gordon
    Headers from the same message sent as a BCC to a "@live.co.uk" address and "@gmail.com" address with no To: field, and below that a header of similar with a To: field.
    First message, sent from [email protected] (gets translated to
    [email protected]) BCCd to
    [email protected] and [email protected] with no To: address.
    Seen in mailbox of [email protected] (note the "to:" field at the bottom - this is what is being shown in the UI):
    x-store-info:J++/JTCzmObr++wNraA4Pa4f5Xd6uensaUSop/gUCq9urBwwSF/6FOwwl1Py7H+wW1z5lc55JnUJDXNvxmGUxkw/bnnWJePWYXWzuS5Ywv2HQzl2GD+3A6SoaKpjD5JlShFHg3JE6so=
    Authentication-Results: hotmail.com; spf=pass (sender IP is 143.52.X.XX)
    [email protected]; dkim=none header.d=shu.ac.uk; x-hmca=pass
    [email protected]
    X-SID-PRA: [email protected]
    X-AUTH-Result: PASS
    X-SID-Result: PASS
    X-Message-Status: n:n
    X-Message-Delivery: Vj0xLjE7dXM9MDtsPTE7YT0xO0Q9MTtHRD0xO1NDTD0w
    X-Message-Info: NhFq/7gR1vQRHV6jbdvQfibhgw1iwvrSqdhXuaSscqGalY1BHnH2KCdI+PRBKCQiYnAlF/zI6HIxnd9XTtPz9XHPDwg5mATFcpFtv9WV5ImszG0/OtQaSIg5iX4MbuVLCVo+t2VN/SyhCbwRod9LNPet1UXZtp+Oho5aLYTKlYQVRQ8OWRHqxMCUhgER4oHof+Be4v85/e3u59xr9Q2GEVPOpY/FDKse
    Received: from MTA2.shu.ac.uk ([143.52.X.XX]) by SNT004-MC4F19.hotmail.com with Microsoft SMTPSVC(7.5.7601.22712);
    Wed, 10 Sep 2014 03:56:32 -0700
    Received: from MTA1 ([10.14.XXX.XXX])
    by MTA2.shu.ac.uk with esmtp (Exim 4.76)
    (envelope-from <[email protected]>)
    id 1XRfZg-0004Kn-9C
    for [email protected]; Wed, 10 Sep 2014 11:56:32 +0100
    Received: from CAS1.shu.ac.uk ([10.14.XX.XX])
    by MTA1 with esmtp (Exim 4.80.1)
    (envelope-from <[email protected]>)
    id 1XRfZg-0002cz-2q; Wed, 10 Sep 2014 11:56:32 +0100
    Received: from MBX1.shu.ac.uk ([xxxx::xxxx:xxxx:xxxx:xxxx]) by
    CAS1.shu.ac.uk ([xxxx::xxxx:10.14.XX.XX%12]) with mapi id
    14.03.0174.001; Wed, 10 Sep 2014 11:56:29 +0100
    From: "user1" <[email protected]>
    Subject: RE: PLease ignore yet again! testing Bcc again - no "to" field
    Thread-Topic: PLease ignore yet again! testing Bcc again - no "to" field
    Thread-Index: Ac/M5d+WfHZZ5GLGRsCfXxvcxsjnbw==
    Date: Wed, 10 Sep 2014 10:56:28 +0000
    Message-ID: <[email protected]>
    Accept-Language: en-GB, en-US
    Content-Language: en-US
    X-MS-Has-Attach:
    X-MS-TNEF-Correlator:
    x-originating-ip: [10.14.XXX.XXX]
    Content-Type: multipart/alternative;
    boundary="_000_24BACA8040C3054487601DFC4087062C8C013974mbx1sh_"
    MIME-Version: 1.0
    to: [email protected]
    Return-Path: [email protected]
    X-OriginalArrivalTime: 10 Sep 2014 10:56:33.0151 (UTC) FILETIME=[E23190F0:01CFCCE5]
    Seen in mailbox of [email protected]:
    Delivered-To: [email protected]
    Received: by 10.25.156.200 with SMTP id f191csp386624lfe;
            Wed, 10 Sep 2014 03:56:32 -0700 (PDT)
    X-Received: by 10.194.200.137 with SMTP id js9mr48633666wjc.90.1410346592418;
            Wed, 10 Sep 2014 03:56:32 -0700 (PDT)
    Return-Path: <[email protected]>
    Received: from MTA1 (MTA1. [143.52.X.XXX])
            by mx.google.com with ESMTPS id cg3si20369633wjc.56.2014.09.10.03.56.32
            for <[email protected]>
            (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
            Wed, 10 Sep 2014 03:56:32 -0700 (PDT)
    Received-SPF: pass (google.com: domain of [email protected] designates 143.52.X.XXX as permitted sender) client-ip=143.52.X.XXX;
    Authentication-Results: mx.google.com;
           spf=pass (google.com: domain of
    [email protected] designates 143.52.X.XXX as permitted sender)
    [email protected]
    Received: from CAS1.shu.ac.uk ([10.14.XX.XX])
    by MTA1 with esmtp (Exim 4.80.1)
    (envelope-from <[email protected]>)
    id 1XRfZg-0002cz-2q; Wed, 10 Sep 2014 11:56:32 +0100
    Received: from MBX1.shu.ac.uk ([xxxx::xxxx:xxxx:xxxx:xxxx]) by
    CAS1.shu.ac.uk ([xxxx::xxxx:10.14.XX.XX%12]) with mapi id
    14.03.0174.001; Wed, 10 Sep 2014 11:56:29 +0100
    From: "user1" <[email protected]>
    Subject: RE: PLease ignore yet again! testing Bcc again - no "to" field
    Thread-Topic: PLease ignore yet again! testing Bcc again - no "to" field
    Thread-Index: Ac/M5d+WfHZZ5GLGRsCfXxvcxsjnbw==
    Date: Wed, 10 Sep 2014 10:56:28 +0000
    Message-ID: <[email protected]>
    Accept-Language: en-GB, en-US
    Content-Language: en-US
    X-MS-Has-Attach:
    X-MS-TNEF-Correlator:
    x-originating-ip: [10.14.XXX.XXX]
    Content-Type: multipart/alternative;
    boundary="_000_24BACA8040C3054487601DFC4087062C8C013974mbx1sh_"
    MIME-Version: 1.0
    Similar message sent with [email protected] in To: field:  from
    [email protected]/[email protected] BCCd to
    [email protected] and
    [email protected] as seen in mailbox of [email protected]
    x-store-info:J++/JTCzmObr++wNraA4Pa4f5Xd6uensaUSop/gUCq9v81cBAiz99O+8SxkfBVJ9NjbAXH8xe1rjvemR/ciBJT5MdkHvi8JYPj0vgDySrSfVnSG2OjgyyKNgjV2QF5PyGqXgRRVkQVM=
    Authentication-Results: hotmail.com; spf=pass (sender IP is 143.52.X.XX)
    [email protected]; dkim=none header.d=shu.ac.uk; x-hmca=pass
    [email protected]
    X-SID-PRA: [email protected]
    X-AUTH-Result: PASS
    X-SID-Result: PASS
    X-Message-Status: n:n
    X-Message-Delivery: Vj0xLjE7dXM9MDtsPTE7YT0xO0Q9MTtHRD0xO1NDTD0w
    X-Message-Info: NhFq/7gR1vTvTqmPqDcS3ZKVZ4zJXdbe/WQhPCDn6U7TYJxfLAm+gALYf9z8EvjEIPauVTBwIF/uNFwreEfp3wgBZYYA8nUP8PFhNAMvRkDwCAnqdyWkFMZlNIQlCYkX84PJFTI7+qoRwxyIjAr2dfuXuj/qYYgN8IbRFD0FftK7d85hSKx/muFfL/1x713Efp1R2ztH/sUzvcxbXl+i8zHWvMqqF945
    Received: from MTA2.shu.ac.uk ([143.52.X.XX]) by BAY004-MC6F14.hotmail.com with Microsoft SMTPSVC(7.5.7601.22712);
    Wed, 10 Sep 2014 05:22:06 -0700
    Received: from MTA1 ([10.14.XXX.XXX])
    by MTA2.shu.ac.uk with esmtp (Exim 4.76)
    (envelope-from <[email protected]>)
    id 1XRguU-0006jA-4s
    for [email protected]; Wed, 10 Sep 2014 13:22:06 +0100
    Received: from CAS2.shu.ac.uk ([10.14.XX.XX])
    by MTA1.shu.ac.uk with esmtp (Exim 4.80.1)
    (envelope-from <[email protected]>)
    id 1XRguU-0001YY-0a; Wed, 10 Sep 2014 13:22:06 +0100
    Received: from MBX1.shu.ac.uk ([xxxx::xxxx:xxxx:xxxx:xxxx]) by
    CAS2.shu.ac.uk ([xxxx::xxxx:10.14.XX.XX%15]) with mapi id
    14.03.0174.001; Wed, 10 Sep 2014 13:22:00 +0100
    From: "user1" <[email protected]>
    Subject: test BCC - using own name in To
    Thread-Topic: test BCC - using own name in To
    Thread-Index: Ac/M8dJDWdvoIxoORH2RMAqNKM2m1w==
    Date: Wed, 10 Sep 2014 12:22:00 +0000
    Message-ID: <[email protected]>
    Accept-Language: en-GB, en-US
    Content-Language: en-US
    X-MS-Has-Attach:
    X-MS-TNEF-Correlator:
    x-originating-ip: [10.14.XXX.XXX]
    Content-Type: multipart/alternative;
    boundary="_000_24BACA8040C3054487601DFC4087062C8C013A65mbx1sh_"
    MIME-Version: 1.0
    To: [email protected]
    Return-Path: [email protected]
    X-OriginalArrivalTime: 10 Sep 2014 12:22:07.0005 (UTC) FILETIME=[D63584D0:01CFCCF1]

    I'm guessing that they're using something other than Exchange for the MTA's. I don't recall seeing this in the "Received:" headers ever since Exchange stopped using the MS Windows SMTP service:
    Microsoft SMTPSVC(7.5.7601.22712)
    --- Rich Matheisen MCSE&I, Exchange MVP

Maybe you are looking for

  • Is it possible to display Footnotes in column layout?

    I have many small footnotes (one or two words). To prevent wasting space with the footnotes I would like to have the footnotes in a two column layout and the body text in one column. Is this possible in Framemaker (latest version)?

  • How to create folders in mail?

    How do I create folders in Mail?

  • How to set default programs???

    How to set default programs? An example: when I click on a .doc it opens in TextEdit, but I want it to open with NeoOffice (to make that happen now requires right-click>open with>NeoOffice) How can I set NeoOffice as the default program for .doc, .xl

  • JSP vs ColdFusion

    I'm trying to do some research on this issue, but most of what I find is very old. Can anybody provide any insight on why JSP might be better than ColdFusion? The primary focus is connecting to databases and producing web pages. Supposedly CF is awes

  • Multithread memory hog, need help

    I have written a program that seeks out a certain type of file from a directory tree structure. the program has to run in as little time as possible, but still has to go through thousands of directories. I threaded the below program but it takes up l