Sending email using java code

Is there an easy way to send email from java code?

+3
source share
5 answers

You can use JavaMail or CommonsEmail (which is built on top of JavaMail)

Here is a simple Commons Mail example taken from this page :

SimpleEmail email = new SimpleEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();
+7
source

If you want the messaging API to be point-incompatible and / or to be able to receive POP3, not just SMTP, check out the JavaMail API . How to use it, it is covered by an excellent FAQ .

API , Apache Commons Email, , JavaMail API. , .

+1

: " jGuru: API JavaMail" - .

it contains fragments of code, as well as explanations of them and mail protocols (in case the developer does not know how each of them behaves).

0
source

Source: https://habr.com/ru/post/1731392/


All Articles