Thx for the tip.
It macth exactly my need.
Just a precision, i had
to code it this way :
Session mailSession = Session.getInstance(props, null);
So the server can be different for each request.
Sorry for this late answer but problems have priorities...
On 5/19/06, David Kerber <[EMAIL PROTECTED]> wrote:
Dynamically-defined mail servers work fine in Tomcat; I'd be in deep
kimshe if they didn't. Here are some excerpts from the code I use:
Properties props = new Properties();
props.put( "mail.smtp.host", <however you get the
server name> );
Session mailSession =
Session.getDefaultInstance(props, null);
msg= new MimeMessage(mailSession);
msg.setRecipients(Message.RecipientType.TO,
internetAddresses);
fromAddress = new InternetAddress( <however you get
the FROM address> );
msg.setFrom( fromAddress );
msg.setSubject( <the subject line> );
...
msg.setText( <the message body content> );
Transport.send(msg);
...
lio tomcat wrote:
> Hello world,
>
> I'm trying to use javamail api in order to fecth/sen mails in a tomcat
> servlet.
> Sor far, it's fine. more : it works.
> But my needs are going beyond this firsyt step.
>
> As i understand, the mail servers (smtp, pop, ...) are defined as
> resources in tomcat (or watever servlet) in its specific config file
> (server.xml).
> Then the servlet is able to retrieve one of these server throught a
> context, a session and a transport objects. Right?
>
> My aim is to build dynamically (by the servlet) a transport with
> parameters received in request. Clear?
>
> By the way, i read :
> "In general, applications should not need to use the classes in this
> package directly.
> Instead, they should use the APIs defined by javax.mail package (and
> subpackages).
> Applications should never construct instances of SMTPTransport directly.
> Instead, they should use the Session method getTransport to acquire an
> appropriate Transport object. "
> (see :
>
file:///C:/lionel/dwd/sw/javamail-1_4/javamail-1.4/docs/javadocs/index.html?index-filesindex-1.html)
>
>
> So i'm wondering how i should use the Session method getTransport to
> acquire an appropriate Transport object.
>
> Or if i should let javamail down and look for another solution.
>
> Any comment/idea/link is welcome
>
> thx,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]