Subversion Repositories bacoAlunos

Rev

Rev 1444 | Rev 1446 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1444 Rev 1445
Line 38... Line 38...
38
 
38
 
39
    }
39
    }
40
 
40
 
41
    static 1.5.0/docs/api/java/lang/String.html">String[] serverEmails;
41
    static 1.5.0/docs/api/java/lang/String.html">String[] serverEmails;
42
    static int serverEmailPos = -1;
42
    static int serverEmailPos = -1;
43
    static Session session = null;
-
 
-
 
43
 
44
 
44
 
45
    static
45
    static
46
    {
46
    {
47
        serverEmails = new 1.5.0/docs/api/java/lang/String.html">String[Globals.EMAIL_SERVER_USER_COUNT];
47
        serverEmails = new 1.5.0/docs/api/java/lang/String.html">String[Globals.EMAIL_SERVER_USER_COUNT];
48
        for(int i = 1;i<= Globals.EMAIL_SERVER_USER_COUNT;i++)
48
        for(int i = 1;i<= Globals.EMAIL_SERVER_USER_COUNT;i++)
49
        {
49
        {
50
            serverEmails[i-1] = Globals.EMAIL_SERVER_USER_PREFIX + i + Globals.EMAIL_SERVER_USER_SUFIX;
50
            serverEmails[i-1] = Globals.EMAIL_SERVER_USER_PREFIX + i + Globals.EMAIL_SERVER_USER_SUFIX;
51
        }
51
        }
52
    }
52
    }
53
 
53
 
54
    public static void connectSession()
54
    public Session connectSession()
55
    {
55
    {
56
        logger.info("CONNECTION SESSION EMAIL");
56
        logger.info("CONNECTION SESSION EMAIL");
57
        sendFromAddress = Globals.SYSTEM_EMAIL_USE_ROUND_ROBIN ?
57
        sendFromAddress = Globals.SYSTEM_EMAIL_USE_ROUND_ROBIN ?
58
                getRoundRobinEmailUser() : Globals.SYSTEM_EMAIL_BOX;
58
                getRoundRobinEmailUser() : Globals.SYSTEM_EMAIL_BOX;
59
 
59
 
Line 105... Line 105...
105
 
105
 
106
 
106
 
107
 
107
 
108
        1.5.0/docs/api/java/lang/System.html">System.out.println("Autenticator != null :" + (authenticator != null));
108
        1.5.0/docs/api/java/lang/System.html">System.out.println("Autenticator != null :" + (authenticator != null));
109
        // Get session
109
        // Get session
110
        session = authenticator != null ?
110
        Session session = authenticator != null ?
111
                Session.getDefaultInstance(props, authenticator)
111
                Session.getDefaultInstance(props, authenticator)
112
                : Session.getDefaultInstance(props) ;
112
                : Session.getDefaultInstance(props) ;
113
 
113
 
114
        /*session = authenticator != null ?
114
        /*session = authenticator != null ?
115
                Session.getInstance(props, authenticator)
115
                Session.getInstance(props, authenticator)
Line 125... Line 125...
125
            logger.error(e,e);
125
            logger.error(e,e);
126
        }
126
        }
127
 
127
 
128
        session.setDebug(true);
128
        session.setDebug(true);
129
        session.setDebugOut(1.5.0/docs/api/java/lang/System.html">System.out);
129
        session.setDebugOut(1.5.0/docs/api/java/lang/System.html">System.out);
130
 
-
 
-
 
130
        return session;
131
 
131
 
132
    }
132
    }
133
    private static synchronized 1.5.0/docs/api/java/lang/String.html">String getRoundRobinEmailUser()
133
    private static synchronized 1.5.0/docs/api/java/lang/String.html">String getRoundRobinEmailUser()
134
    {
134
    {
135
        serverEmailPos++;
135
        serverEmailPos++;
Line 153... Line 153...
153
            logger.warn(warn);
153
            logger.warn(warn);
154
            return;
154
            return;
155
        }
155
        }
156
        try{
156
        try{
157
 
157
 
158
 
-
 
-
 
158
            //if(session == null || !session.getTransport().isConnected())
-
 
159
               Session session = connectSession();
159
 
160
 
160
 
161
 
161
 
162
 
162
 
163
 
163
            // Create message
164
            // Create message
Line 239... Line 240...
239
                message.setHeader("Content-Transfer-Encoding", "quoted-printable");
240
                message.setHeader("Content-Transfer-Encoding", "quoted-printable");
240
                logger.info("Sending email to transport:"+fullMessage);
241
                logger.info("Sending email to transport:"+fullMessage);
241
 
242
 
242
 
243
 
243
 
244
 
244
                if(session == null || !session.getTransport().isConnected())
-
 
245
                    connectSession();
-
 
-
 
245
 
246
                Transport.send(message);
246
                Transport.send(message);
247
                //session.getTransport("smtp").sendMessage(message,message.getAllRecipients());
247
                //session.getTransport("smtp").sendMessage(message,message.getAllRecipients());
248
                //session.getTransport().close();
248
                //session.getTransport().close();
249
            }
249
            }
250
        }
250
        }