Questions tagged [jakarta-mail]

A Java API to send and receive emails. Jakarta Mail (previously JavaMail) is part of Jakarta EE (previously Java EE), but can also be used in Java SE via a separate download.

Jakarta Mail (previously JavaMail) is a Java API used to send and receive email via SMTP, POP3 and IMAP. Jakarta Mail is built into the Jakarta EE platform, but also provides an optional package for use in Java SE.

The current version and last release in the 1.x line is 1.6.5, released on March 10, 2020. Another open source JavaMail implementation exists - GNU JavaMail - while supporting only version 1.3 of the JavaMail specification, it provides the only free NNTP backend, which makes it possible to use this technology to read and send news group articles.

In 2018 JavaMail became part of the EE4J initiative under the Eclipse Foundation, and was renamed to Jakarta Mail.

Useful links

Related Tags:

5196 questions
699
votes
25 answers

Sending Email in Android using JavaMail API without using the default/built-in app

I am trying to create a mail sending application in Android. If I use: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); This will launch the built-in Android application; I'm trying to send the mail on button click directly…
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
599
votes
48 answers

Error - trustAnchors parameter must be non-empty

I'm trying to configure my e-mail on Jenkins/Hudson, and I constantly receive the error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty I've seen a good amount of information online about the…
David Gill
  • 8,411
  • 5
  • 19
  • 21
219
votes
14 answers

How can I send an email by Java application using GMail, Yahoo, or Hotmail?

Is it possible to send an email from my Java application using a GMail account? I have configured my company mail server with Java app to send email, but that's not going to cut it when I distribute the application. Answers with any of using…
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
159
votes
8 answers

java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger for JUnit test case for Java mail

I am using Java Mail API to read and parse emails. It is working fine with Servlet code. Now I am trying to write a JUnit test case for the same purpose. But on line Session session = Session.getDefaultInstance(properties); I am getting the…
user2215139
  • 1,805
  • 2
  • 18
  • 24
133
votes
10 answers

How do I send an HTML email?

I have successfully sent email in my web application using JMS, but the result only displays in plain text. I want the content to be able to display html. How do I do it? Here is roughly what I have: Message msg = new MimeMessage(mailSession); try{ …
Thang Pham
  • 38,125
  • 75
  • 201
  • 285
100
votes
5 answers

Download attachments using Java Mail

Now that I`ve downloaded all the messages, and store them to Message[] temp; How do I get the list of attachments for each of those messages to List attachments; Note: no thirdparty libs, please, just JavaMail.
George
  • 8,368
  • 12
  • 65
  • 106
95
votes
12 answers

Send mail to multiple recipients in Java

I want to send a message to multiple Recipients using following the method: message.addRecipient(Message.RecipientType.TO, String arg1); Or message.setRecipients(Message.RecipientType.TO,String arg1); But one confusion is that in the second…
Prateek
  • 12,014
  • 12
  • 60
  • 81
91
votes
3 answers

Which artifact for org.springframework.mail?

I'd like to use spring support for sending mails. My project is built with maven-2 and I use spring-core 2.5.5 I tried to look in maven central repo for artifact to include in my pom.xml, and the only one I found is spring support. The problem is…
Tadeusz Kopec for Ukraine
  • 12,283
  • 6
  • 56
  • 83
76
votes
10 answers

Getting mail from GMail into Java application using IMAP

I want to access messages in Gmail from a Java application using JavaMail and IMAP. Why am I getting a SocketTimeoutException ? Here is my code: Properties props = System.getProperties(); props.setProperty("mail.imap.host",…
Dave of San Ramon
  • 1,471
  • 1
  • 11
  • 8
69
votes
17 answers

javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted

I am getting this error when I try to send mail using the JavaMail API: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted How can I fix this?
Rohit Raj
  • 801
  • 1
  • 6
  • 4
68
votes
13 answers

package javax.mail and javax.mail.internet do not exist

When I compile a simple code that has the following 2 import statements: import javax.mail.* import javax.mail.internet.* I get the following message: package javax.mail does not exist package javax.mail.internet does not exist Why do I get this…
saplingPro
  • 20,769
  • 53
  • 137
  • 195
68
votes
8 answers

UTF-8 charset doesn't work with javax.mail

I have used Java Mail API, for sending emails. I am using a contact formular to send the input, which has to be send to a specific email. The email is send without problems, though I am a danish guy, and I am therefore in need of three danish…
Martin Rohwedder
  • 1,712
  • 4
  • 19
  • 34
67
votes
10 answers

How to read text inside body of mail using javax.mail

i'm developing a client mail using javax.mail to read mail inside mail box: Properties properties = System.getProperties(); properties.setProperty("mail.store.protocol", "imap"); try { Session session =…
Jayyrus
  • 12,961
  • 41
  • 132
  • 214
65
votes
2 answers

how to send HTML email

I have to send HTML file via email but not as attachment. Message simpleMessage = new MimeMessage(mailSession); try { fromAddress = new InternetAddress(from); toAddress = new InternetAddress(to); } catch (AddressException e) { // TODO…
Prerna
  • 1,235
  • 4
  • 17
  • 22
63
votes
11 answers

GoDaddy SSL Cert Not Working With Java

UPDATE 1/26/2015 -- It appears the most recent JRE/JDK for Java 8 (update >= 31) and JRE/JDK for Java 7 now include the Godaddy G2 CA server in the default trust store. If possible, it's urged you upgrade your JRE/JDK to the latest Java 8 update to…
SnakeDoc
  • 13,611
  • 17
  • 65
  • 97
1
2 3
99 100