Questions tagged [apache-commons-email]

Apache Commons Email aims to provide a API for sending email. It is built on top of the Java Mail API, which it aims to simplify.

Apache Commons Email aims to provide a API for sending email. It is built on top of the Java Mail API, which it aims to simplify.

Some of the mail classes that are provided are as follows:

  • SimpleEmail - This class is used to send basic text based emails.
  • MultiPartEmail - This class is used to send multipart messages. This allows a text message with attachments, either inline or attached.
  • HtmlEmail - This class is used to send HTML formatted emails. It has all the capabilities of MultiPartEmail, allowing attachments to be easily added. It also supports embedded images.
  • ImageHtmlEmail - This class is used to send HTML formatted emails with inline images. It has all the capabilities of HtmlEmail but transforms all image references to inline images.
  • EmailAttachment - This is a simple container class to allow for easy handling of attachments. It is for use with instances of MultiPartEmail and HtmlEmail.

Official Website: http://commons.apache.org/email/

Useful Links:

Related Tags:

86 questions
19
votes
3 answers

How change charset in Apache Commons Email?

I'm using Apache Commons email to send email to my clients, but I have a client called 'Semana da Computação' (in portugues BR) but it goes 'Semana da Computação' . I try to modify my code, but it nothing working: public static boolean…
Valter Silva
  • 16,446
  • 52
  • 137
  • 218
12
votes
3 answers

Sending email in Java using Apache Commons email libs

I am using Apache Commons Email library to send emails, but I am not able to send them via GMail SMTP server. Can anyone provide sample code which works with GMail SMTP server and others? I am using the following code which does not work: String[]…
user93796
  • 18,749
  • 31
  • 94
  • 150
10
votes
2 answers

Apache Commons Email and UTF-8

How do you change the encoding of an email generated with Apache Commons Email to UTF-8? I want to send emails I generate depending on the receiver's language, and I need to take in account Japanese and Russian. Problem is: the Email class doesn't…
Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124
10
votes
6 answers

How to attach a file to an HTML email using Apache Commons Email

I'm using Apache Commons Email 1.1 and I can't figure out how to attach a file to an HtmlEmail. If I run the code below, I get an email with an attachment, but the HTML message comes across as an attachment also. If I don't call email.attach() the…
delux247
  • 2,177
  • 3
  • 21
  • 29
9
votes
3 answers

How to send multiple emails in one session?

I want to send thousands of different emails to different recipients and would like to open the connection to my SMTP and hold it. I hope this is faster then reopen the connection for ervy mail. I would like to use Apache Commons Email for that, but…
Tim Büthe
  • 62,884
  • 17
  • 92
  • 129
9
votes
5 answers

Sending an Email Using Commons-Email to Gmail

Email email = new SimpleEmail(); String authuser = "......@gmail.com"; String authpwd = "*******"; // Very Important, Don't use email.setAuthentication() email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(authuser,…
user217029
  • 101
  • 1
  • 2
  • 4
7
votes
1 answer

add attachment as stream in commons email

I am using Apache Commons Email in my web-application and it works fine. Now that I need to send a document by attachment, I am facing some problems. I need to get the file from the database (as a BLOB) and add it as an attachment. It seems like…
user644745
  • 5,673
  • 9
  • 54
  • 80
6
votes
2 answers

Apache Commons Email and Reusing SMTP Connections

Currently I am using Commons Email to send email messages, but I have not been able to find a way to share smtp connections between emails sent. I have code like the following: Email email = new SimpleEmail(); …
Ransom Briggs
  • 3,025
  • 3
  • 32
  • 46
4
votes
2 answers

Setting the Bounce Address in Apache Commons Mail

Using the Apache Commons to send email there is the following code. HtmlEmail email = new HtmlEmail(); email.setHostName(SMTP_HOST_NAME); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator(SMTP_AUTH_USER,…
Milhous
  • 14,473
  • 16
  • 63
  • 82
4
votes
2 answers

Apache Commons Email encode attach with base64

I'm trying to send a file base64-encoded via apache.commons.mail and I just can't seam to get the Content-Transfer-Encoding: base64 header where it's supposed to go. // Create the email MultiPartEmail email = new…
Frankie
  • 24,627
  • 10
  • 79
  • 121
3
votes
0 answers

Alternative for org.apache.commons.mail.util.MimeMessageParser compatible with Jakarta on Java 17

As I updated my Spring Boot application to Java 17 and Spring Boot 3, I migrated from Java EE to Jakarta. I used the MimeMessageParser of org.apache.commons.mail.util.MimeMessageParser, but it expects a javax.mail.internet.MimeMessage rather than a…
3
votes
0 answers

Emails does not save in Sent folder when using SMTP

I'm using Apache Commons Email in user application for mailing purposes. Letters sends succusfully and client recieves it. The problem is sent emails does not save in Sent folder on server. My code: MultiPartEmail email = new…
rozerro
  • 5,787
  • 9
  • 46
  • 94
3
votes
3 answers

Error in sending email using commons-email-1.3

While sending email I am getting the following errors using commons-email-1.3. I have downloaded and added external jar's to the project. Please help me fix this problem! package mypkg; import org.apache.commons.mail.DefaultAuthenticator; import…
H4SN
  • 1,482
  • 3
  • 24
  • 43
3
votes
2 answers

Sending email with java Apache Commons Mail through Lotus Notes

I'm having trouble with my e-mail configuration for sending e-mails using lotus notes in a java program. I know this is pretty much straight forward but i guess i'm missing something. My code is as follows; import java.util.logging.Level; import…
ides
  • 369
  • 6
  • 16
3
votes
1 answer

Apache Commons Email, how to email attachment with Content-Transfer-Type as quoted-printable?

I have an app that talks to someone else's server by sending emails with attachments. I used Apache Commons Email to send the email with attachment like so: MultiPartEmail email = new…
user550738
1
2 3 4 5 6