Here's sendMail method:

                Properties props = new ConfigLoader().loadConfigFile();
                String prop;
                prop=(String)props.get("summary_header");
                if(prop!=null)
                    summary=prop+"\n"+summary;
                prop= (String) props.get("mail.smtp.host");
                props.put( "mail.smtp.host",prop);
                prop= (String) props.get("mail.smtp.port");
                props.put("mail.smtp.port",prop);
               Session session = Session.getDefaultInstance(props);
                Message message = new MimeMessage( session );

                InternetAddress from = new InternetAddress((String) p           
         rops.get("internet_address"));
                InternetAddress to[] = InternetAddress.parse( userEmail );

                message.setFrom( from );
                message.setRecipients( Message.RecipientType.TO, to );
                message.setSubject((String)props.getProperty("subject"));
                message.setSentDate( new Date() );
                message.setText( summary );
                Transport.send(message);

David Smith <[EMAIL PROTECTED]> ha scritto: Seems to me the important part of 
this is the sendMail method.  Could 
you post that?

--David

Fabio Rossi wrote:
> Hi. I'll try to explain my problem, that is about sending an email with 
> JavaMail API from a servlet. Anyway, it seems to be a more general problem 
> i'm having with servlet. I'm using Tomcat 5.0. I've a servlet that process a 
> request, writes to a database some info and then send a email with a summary 
> to the user.
>
> In the method sendMail() i send the email. I test the method in isolation and 
> it works fine. I can connect to my local smtp server and send the email...
> Here's the code:
>
> do some stuff.....and send the email
>
> logInfo("Sending summary email");
>         sendMail(summary.toString(),clientEmail);
>         response.setStatus(HttpServletResponse.SC_OK);
>         logInfo("Email sent");
>         }catch(Exception e){
>             logError("Error sending summary mail to address: "+clientEmail,e);
>             e.printStackTrace();
>         }
>     }
>
> No exceptions are throwed...but it seems that the servlet doesn't "wait" for 
> the method. When i test the method in isolation, it takes some seconds before 
> the mail is sent, and in the smtp local server application i can see that a 
> connection has been established. 
>
> If i call the same code (the sendMail method) from the servlet i get "Email 
> Sent" log messagge immediately and the servlet "exit"..like if the message 
> was sent. But nothing has happened (no connection is established with the 
> local smtp server) and no exception is thrown..
>
>
> Anyone can help me?
>
>
>         
> ---------------------------------
>
> ---------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



       
---------------------------------

---------------------------------
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail

Reply via email to