From: Rhino on
I'd like to send the occasional email from Java servlets but I'm struggling
to figure out the best way to do that in 2010.

I am trying to get some older servlets working again after a long absence
from Java. One of the tasks that some of my servlets did occasionally was
to send emails. It seems I used to use a jar that I got from the O'Reilly
website, dated 2002, which I have long since lost after a hard drive crash.
I'm not having any luck finding it at the O'Reilly site now and I'm
guessing that it's out of date anyway at this point.

Can anyone point me to a modern example of how to send email with a
servlet, as well as where I can find the jar(s) needed, assuming that they
aren't built into Java somewhere?

I've been googling for examples but most are undated, use the same O'Reilly
jar that I was using (without supplying a working link where I can get it
again), or are very old.

--
Rhino
From: Rhino on
Rhino <no.offline.contact.please(a)example.com> wrote in
news:Xns9D5BA9382E35Fnoofflinecontactplea(a)94.75.214.39:

> I'd like to send the occasional email from Java servlets but I'm
> struggling to figure out the best way to do that in 2010.
>
> I am trying to get some older servlets working again after a long
> absence from Java. One of the tasks that some of my servlets did
> occasionally was to send emails. It seems I used to use a jar that I
> got from the O'Reilly website, dated 2002, which I have long since
> lost after a hard drive crash. I'm not having any luck finding it at
> the O'Reilly site now and I'm guessing that it's out of date anyway at
> this point.
>
FWIW, I found a newer version of the O'Reilly classes that I'd been using
before at http://www.servlets.com/cos/. This one is dated Dec 26, 2008 so
it is clearly much fresher.

> Can anyone point me to a modern example of how to send email with a
> servlet, as well as where I can find the jar(s) needed, assuming that
> they aren't built into Java somewhere?
>

> I've been googling for examples but most are undated, use the same
> O'Reilly jar that I was using (without supplying a working link where
> I can get it again), or are very old.
>

It looks like my old code compiles okay with the new jar although some
things got deprecated since 2002. I'll have to go through the API and see
what code changes I need to make. I'll be back if I can't figure them out.



--
Rhino
From: Martin Gregorie on
On Thu, 15 Apr 2010 20:38:07 +0000, Rhino wrote:

> Can anyone point me to a modern example of how to send email with a
> servlet, as well as where I can find the jar(s) needed, assuming that
> they aren't built into Java somewhere?
>
JavaMail? Its a standard Sun/Oracle package.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
From: Arne Vajhøj on
On 15-04-2010 16:38, Rhino wrote:
> I'd like to send the occasional email from Java servlets but I'm struggling
> to figure out the best way to do that in 2010.
>
> I am trying to get some older servlets working again after a long absence
> from Java. One of the tasks that some of my servlets did occasionally was
> to send emails. It seems I used to use a jar that I got from the O'Reilly
> website, dated 2002, which I have long since lost after a hard drive crash.
> I'm not having any luck finding it at the O'Reilly site now and I'm
> guessing that it's out of date anyway at this point.
>
> Can anyone point me to a modern example of how to send email with a
> servlet, as well as where I can find the jar(s) needed, assuming that they
> aren't built into Java somewhere?
>
> I've been googling for examples but most are undated, use the same O'Reilly
> jar that I was using (without supplying a working link where I can get it
> again), or are very old.

Support for sending email is built into Java EE, so no need
for any third party package at all.

It can be a problem for Java SE apps - they need to get
a separate JavaMail package, but in servlet context you
already have JavaMail.

There are lots of JavaMail examples on the net available, but
if you have a specific problem (multipart, HTML format, attachments
etc.) then ask and I will see if I have an example on the shelf.

Arne