How do I send email from a servlet?

Alex Chaffee

From: James Cooper (pixel@bitmechanic.com)

GSP and GnuJSP both come with SMTP classes that make sending email very simple. if you are writing your own servlet you could grab one of the many SMTP implementations from www.gamelan.com (search for SMTP and java). All the ones I've seen are pretty much the same -- open a socket on port 25 and drop the mail off. so you have to have a mail server running that will accept mail from the machine JServ is running on.

See also the JavaMail FAQ for a good list of Java mail resources, including SMTP and POP classes.