How do I send an e-mail in Java?

后端 未结 11 1449
一整个雨季
一整个雨季 2020-12-01 01:55

I need to send e-mails from a servlet running within Tomcat. I\'ll always send to the same recipient with the same subject, but with different contents.

What\'s a sim

11条回答
  •  有刺的猬
    2020-12-01 02:45

    JavaMail can be a bit of a pain to use. If you want a simpler, cleaner, solution then have a look at the Spring wrapper for JavaMail. The reference docs are here:

    http://static.springframework.org/spring/docs/2.5.x/reference/mail.html

    However, this does mean you need Spring in your application, if that isn't an option then you could look at another opensource wrapper such as simple-java-mail:

    simplejavamail.org

    Alternatively, you can use JavaMail directly, but the two solutions above are easier and cleaner ways to send email in Java.

提交回复
热议问题