Giter Club home page Giter Club logo

simple-java-mail's Introduction

APACHE v2 License Latest Release Javadocs Codacy Java 8+

Simple Java Mail

Simple Java Mail is the simplest to use lightweight mailing library for Java, while being able to send complex emails including Batch processing and server clusters, CLI support, authenticated socks proxy(!), attachments, embedded images, custom headers and properties, robust address validation, build pattern and even DKIM signing, S/MIME support and external configuration files, Spring support and Email conversion tools (including support for Outlook).

Just send your emails without dealing with RFCs.

The Simple Java Mail library is a thin layer on top of Angus Mail (previously Jakarta Mail) that allows users to define emails on a high abstraction level without having to deal with mumbo jumbo such as 'multipart' and 'mimemessage'.

Simple Java Mail is available in Maven Central:

<dependency>
    <groupId>org.simplejavamail</groupId>
    <artifactId>simple-java-mail</artifactId>
    <version>8.8.4</version>
</dependency>

Read about additional modules you can add here: simplejavamail.org/modules.

Latest Progress

v8.8.0 - v8.8.4

  • v8.8.4 (23-April-2024): #506: [CVE] Upgrade utils-mail-smime dependency to 2.3.2, to resolve CVE issue in bouncycastle
  • v8.8.3 (13-April-2024): #502: [Bug] Message headers not treated with case insensitivity as per RFC, causing deviating headers to slip through the filters
  • v8.8.2 (05-April-2024): #495: Add config support for 'verifyingServerIdentity' with SMTP, also: since Angus 1.1.0 (8.6.0) server identity checks are on by default and can be countered by mailerBuilder.verifyingServerIdentity(false)
  • v8.8.2 (05-April-2024): #501: [dependency] Update outlook-message-parser dependency, which has improved support for X500 addresses
  • v8.8.2 (05-April-2024): #499 (fix): [maintenance] Added missing finer-grained DKIM Spring Boot properties
  • v8.8.1 (04-April-2024): #500: [bug] Fix parsing addresses from headers in EML files, like a Disposition-Notification-To with umlaut
  • v8.8.0 (22-March-2024): #499: [Enhancement] Expose finer-grained DKIM configuration through the builder api and disable 'l-param' by default)

NOTE: release 8.8.0 changes the default for DKIM signing from 'l-param' true to false. If you rely on this feature, you need to enable it explicitly. Refer to the DKIM documentation for the update.

v8.7.0 - v8.7.1

  • v8.7.1 (20-March-2024): #498: Make S/MIME algorithms configurable (signature algorithm for signing, key encapsulation and cipher algorithms for encryption)
  • v8.7.1 (20-March-2024): #497: Order of attachments is lost when converting a MimeMessage to an Email
  • v8.7.0 (20-March-2024): don't use this version: versioning messed up

NOTE: this breaks the API for S/MIME related builder methods. Refer to the S/MIME documentation for the new API.

v8.6.0 - v8.6.3

  • v8.6.3 (13-February-2024): #491: [bug] Attachment body parts should separately parse Content-Disposition and ContentID, possible resulting in an downloadable attachment that is also embedded
  • v8.6.2 (27-January-2024): #493: [bug] don't require smime-module when adding collection of headers (also used when copying email)
  • v8.6.1 (18-January-2024): #487: Move header filtering from MimeMessageParser to EmailConverter, thereby enabling access to all parsed headers when using MimeMessageParser directly
  • v8.6.1 (18-January-2024): #489: Finished update to Angus Mail by updating activation dependency
  • v8.6.0 (17-January-2024): #489: Update to Angus Mail

NOTE: this release switches to Angus Mail which should be a transparent change, but if you encounter any issues, please report them. One known issue is that Angus, since 1.1.0, performs server identity checks by default, which was previously disabled for SMTP. If you encounter issues with this, you can disable it with mailerBuilder.verifyingServerIdentity(false) and starting from 8.8.2, this also works with SMTP transport strategy (see #495).

v8.5.0 - v8.5.1

  • v8.5.1 (15-December-2023): #486: [dependency] Handle Outlook's Non-Standard S/MIME Signed Messages
  • v8.5.0 (13-December-2023): #484: [bug] Addresses passed as string are not always interpreted correctly

v8.4.0 (12-December-2023)

  • #483: Enhancement: add native support for overriding envelope-level receiver(s)

v8.3.0 - v8.3.5

  • v8.3.5 (10-December-2023): #482 Bug: 'IllegalArgumentException: emailAddressList is required' when parsing mail with incorrect recipients from Outlook message
  • v8.3.4 (08-December-2023): #481 Enhancement: don't crash on invalid empty embedded images when parsing Outlook messages
  • v8.3.3 (03-December-2023): #477 Enhancement: Support Exchange proprietary addresses (X.500 DAP)
  • v8.3.2 (26-November-2023): #480 Bug: Multiple attachments with same name get the same Content-ID, causing them to refer to the same file content
  • v8.3.1 (09-October-2023): #440 Bug: names manually specified for embedded images are overridden and have extension added, breaking cid: references in HTML body
  • v8.3.0 (09-October-2023): #475 Enhancement: Add configuration metadata for Spring Boot application properties

v8.2.0 (02-October-2023)

  • #473 Bugfix: Add missing support for multiple reply-to addresses

v8.1.0 - v8.1.3

  • v8.1.3 (14-July-2023): #467 Security: Medium severity vulnerability is detected in org.bouncycastle transitive dependency
  • v8.1.3 (14-July-2023): #466 Maintenance: Let Mailer implement AutoCloseable, so it shuts down the connection pool automatically when disposed of by Spring
  • v8.1.2 (23-June-2023): #465 Regression bug #461: Simple Java Mail always requires DKIM/SMIME modules
  • v8.1.1 (07-June-2023): #461 Bugfix: Fixed MessageID not preserved when signing/encrypting with S/MIME and/or DKIM
  • v8.1.0 (15-April-2023): #458 Missing osgi headers (#288) and added support for Apache Karaf
  • v8.1.0 (15-April-2023): #288 Maintenance: missing OSGI package-exports from core-module

v8.0.0 - v8.0.1

  • v8.0.1 (30-April-2023): #456: Enhancement: make Content-Transfer encoder detection more lenient, supporting more values from the wild
  • v8.0.0 (08-March-2023): #451: Feature: Make defaults and overrides a first class feature
  • v8.0.0 (08-March-2023): #452: Enhancement: with ".disableAllClientValidation(true)", also ignore errors from the completeness check
  • v8.0.0 (08-March-2023): #450: Bug: when using dispositionNotificationTo or returnReceiptTo mode, when the corresponding emails are not filled, it fails even though it should fall back to replyTo or From
  • v8.0.0 (08-March-2023): #449: Bug: IllegalArgumentException on parsing empty header name and value (when parsing Outlook message)
  • v8.0.0 (08-March-2023): #448: Bug: withEmailDefaults and withEmailOverrides does not work with CustomMailer
  • v8.0.0 (08-March-2023): #447: Enhancement: allow defaults/overrides to ignore individual fields (turn off for specific properties)
  • v8.0.0 (08-March-2023): #446: Enhancement: add missing defaults properties for DKIM

This release changes how Email instances are built, or more specifically, when defaults and overrides are applied. There are now overloaded build methods that provide similar behaviour as previous versions.

v7.9.0 - v7.9.1

  • v7.9.1 (22-February-2023): #444 Bugfix: encoded delimited recipients in EML not parsed properly
  • v7.9.0 (21-February-2023): #344 Enhancement: make DKIM signing more flexible by allowing header exclusions in DKIM signature

v7.8.0 - v7.8.3

  • v7.8.3 (21-February-2023): #293 Bugfix: Decoding missing in a few placed when parsing MimeMessage or sending an Email
  • v7.8.2 (09-February-2023): #442 Enhancement: Simple Java Mail should throw an exception when trying to utilize S/MIME with smime-module on the classpath
  • v7.8.1 (01-February-2023): #438 Bug: properly Fail-Fast in case of Transport claim timeout in the batch-module, rather than running into NPE further down the line
  • v7.8.0 (24-January-2023): #436 Enhancement: add mailerBuilder.withTransportModeLoggingOnly() as mailer API entry point
  • v7.8.0 (24-January-2023): #435 Enhancement: SMTP server config should be optional in case a CustomMailer is used
  • v7.8.0 (24-January-2023): #427 Feature: set a maximum email size on Mailer level which throws EmailToBig exception when exceeded

v7.7.0 - v7.7.1

  • v7.7.1 (18-January-2023): #434 Regression bug in #430: Email parameter missing in CustomMailer interface
  • v7.7.0 (17-January-2023): #430 Enhancement: auto-reconnect (if needed) when reclaiming a Transport connection from the SMTP connection
  • v7.7.0 (17-January-2023): #383 Feature: be able to set defaults and overrides on the Mailer level, rather than email or global level

7.7.0 moves the conversion of Email to MimeMessage to after a Transport instance has been selected (in case of a cluster of SMTP servers), so we can apply defaults/overrides on the Mailer level, meaning you can configure 'global' values for individual SMTP servers (like a fixed FROM per server).

v7.6.0 (05-January-2023)

  • #421 Enhancement: Add support for OAUTH2 authentication

v7.5.0 - v7.5.2

  • v7.5.2 (25-December-2022): #429 Bug: wrong username property used when password authentication is not needed
  • v7.5.1 (12-December-2022): #416 Bug: Support encoder names regardless of their case ("base64" is the same as "BASE64")
  • v7.5.1 (12-December-2022): #424 Maintenance: bump JMail dependency from 1.2.1 to 1.4.1
  • v7.5.0 (28-July-2022): #411 Enhancement: expose validation sub steps in the MailerHelper class for the completeness check, CRLF inject scans and address validations
  • v7.5.0 (28-July-2022): #410 Bug: CRLF injection scan missing for dispositionNotificationTo and returnReceiptTo
  • v7.5.0 (28-July-2022): #390 Enhancement: make client sided validation optional, turning off address validation and CRLF injection detection

v7.5.1 (12-December-2022)

  • #416 Bug: Support encoder names regardless of their case ("base64" is the same as "BASE64")
  • #424 Maintenance: bump JMail dependency from 1.2.1 to 1.4.1

v7.5.0 (28-July-2022)

  • #411 Enhancement: expose validation sub steps in the MailerHelper class for the completeness check, CRLF inject scans and address validations
  • #410 Bug: CRLF injection scan missing for dispositionNotificationTo and returnReceiptTo
  • #390 Enhancement: make client sided validation optional, turning off address validation and CRLF injection detection

v7.4.0 (19-July-2022)

  • #407 Enhancement: Process all Outlook message headers, either copying the as-is or translating them to respective Simple Java Mail API calls
  • #404 Minor bugfix: the new attachment's contentDescription was missing in Email.toString()

v7.3.0 (15-July-2022)

  • #405 Feature: Expand email builder API to support forced content Content-Transfer-Encoding for attachments, like quoted-printable, base64, 7BIT and others
  • #404 Feature: Expand email builder API to support Content-Description on attachments

v7.2.0 - v7.2.1

  • v7.2.1 (13-July-2022): #396 Enhancement: make Outlook support tolerant of invalid/empty nested Outlook message attachments
  • v7.2.0 (13-July-2022): #399 Feature: Expand email builder API to support selective content encoding, like quoted-printable, base64, 7BIT and others

v7.1.0 - v7.1.3

  • v7.1.3 (12-July-2022): #403 Security: Bump zip4j (only used during testing)
  • v7.1.2 (12-July-2022): #401 Enhancement: Add HEIC and WEBP support when dynamically resolving embedded images from classpath
  • v7.1.2 (12-July-2022): #402 Security: Update Log4j to 2.17.1
  • v7.1.2 (12-July-2022): #393 Security: Update Apache POI and POI Scratchpad
  • v7.1.1 (27-March-2022): #387 Bug: memory leak in SMPT connection pool when 3rd party deallocation failed with exception
  • v7.1.0 (25-January-2022): #379 Maintenance: Adjust dependencies and make Java 9+ friendly

v7.0.1 - v7.0.2

  • v7.0.2 (25-January-2022): #329 Enhancement: Exceptions cause error-level logging in addition to rethrowing the exception, but should just include the message in a custom exception
  • v7.0.2 (25-January-2022): #378 Bug: package org.simplejavamail.internal.modules causes split package problem in Java9+
  • v7.0.1 (22-January-2022): #375 Bug: batch-module gives error when there is a custom mailer

v7.0.0 (2-January-2022)

It has been two years since the last major release, but 7.0.0 finally here!

What's new

Major features:

  • #322 Simple Java Mail migrated to Java 8 finally (see notes below)
  • #295 And also switched to JavaMail's successor Jakarta Mail 2.0.1 (see notes below)
  • #323 Solved the great CLI performance problem (now executes near instantly)
  • #319 Replaced the underlying regex-based email-address validation library with the lexer based JMail, which is faster, correcter, documented better and is more up-to-date with RFC's
  • #367 The sendMail/testConnection methods now have proper support for CompletableFuture

Bugfixes:

  • #352 Bug: names regex groups are not supported in Android JVM
  • #326 Bug: NullPointer when parsing Outlook Message with nested empty Outlook message
  • #330 Bug: cli expected --mailer arguments duplicated 3 times
  • #324 Bug: Add back missing log4j2 for CLI library

Maintenance:

  • #368 Resolve log4j (Java8) vulnerability in Simple Java Mail's CLI module
  • #330 Improved feedback from failing CLI commands
  • #327 Implement toString() for Mailer instances for debugging purposes

About the migration

Updating to Java8/Jakarta 2.0.1 posed a challenge as the 3rd party S/MIME library java-utils-mail-smime has been abandoned/archived while developing Simple Java Mail. Furthermore, it was still under LGPL3 license while everything else is ApacheV2.

Thankfully, I obtained permissions from the maintainers -as well as original developers from decades ago on SourceForge- to take both java-utils-mail-smime and java-utils-mail-dkim under my wings at Simple Java Mail and change the licensing model! You can now post issues and pull requests here:

v6.7.0 - v6.7.6

  • v6.7.6 (22-January-2022): #375 Bug: batch-module gives error when there is a custom mailer
  • v6.7.5 (26-December-2021): #338 Enhancement: Also return AsyncResponse from plain Mailer.sendEmail(singleArgument) as async can be configured through MailerBuilder now
  • v6.7.4 (25-December-2021): #331 Enhancement: Coalesce empty SMTP server arguments to null to support CLI better
  • v6.7.3 (25-December-2021): #335 Bugfix: Precondition nonNull check also checks nonEmpty and breaks on clearEmailAddressCriteria
  • v6.7.2 (25-December-2021): #318 Maintenance: Allow zero data attachments so Outlook message conversions don't crash and burn
  • v6.7.1 (25-December-2021): #346 Bugfix: Add option to parse MimeMessage without fetching attachment data from server - Properly return named datasource without fetching all the data if unwanted
  • v6.7.0 (25-December-2021): #356 Enhancement: Improve for support for Android < 8.0 (Fix NoClassDefFoundError)
  • v6.7.0 (25-December-2021): #351 Bugfix: emlToEmail() and mimeMessageToEmail() break on mesages with duplicate names and legacy empty nested messages
  • v6.7.0 (25-December-2021): #347 Maintenance: Reduce log-spam and prevent exception on every module availability check
  • v6.7.0 (25-December-2021): #346 Feature: Add option to parse MimeMessage without fetching attachment data from server

v6.6.0 - v6.6.2

  • v6.6.2 (23-December-2021): #365 Security: Resolve log4j vulnerability in Simple Java Mail
  • v6.6.1 (12-June-2021): #321 Enhancement: Ignore malformed recipient addresses and continue parsing email data
  • v6.6.0 (1-June-2021): #320 Enhancement: Added default S/MIME signing to Mailer level and fixed crippling performance bug

v6.5.0 - v6.5.4

  • v6.5.4 (22-May-2021): #315 Enhancement: Nested attachments of Outlook message attachments are now preserved as standard EML MimeMessage attachments

    NOTE: This removes the Kryo dependency

  • v6.5.3 (4-May-2021): #314 Bugfix: Nested attachments of Outlook message attachments are now preserved, by utilizing Kryo

    NOTE: This add Kryo as extra dependency to the outlook-module (and is subsequently removed in 6.5.4)

  • v6.5.2 (15-April-2021): #311 Bugfix: text/calendar as string -> ClassCastException (if calendar type is not Inputstream)

  • v6.5.1 (10-April-2021): #307 / #310 Bugfix: embedded image resource name got mangled

  • v6.5.0 (16-February-2021): #298 Enhancement: Nested Outlook messages aren't discarded anymore, but parsed to serialized Email objects

  • v6.5.0 (16-February-2021): #292 Bugfix: NullPointerException in SmimeUtilFixed when protocol is missing (which is valid)

  • v6.5.0 (16-February-2021): #289 Bugfix: Support multiple headers with same key

This release breaks all GET/SET api regarding headers used as map (Map<String, T> -> Map<String, Collection<T>>) This release might break api in the rare case you relied on the attachment list and you have nested Outlook .msg attachments (previously omitted in the results)

v6.4.0 - v6.4.5

  • v6.4.5 (13-Februari-2021): #306 Maintenance: Update outlook-message-parser to 1.7.9
  • v6.4.5 (13-Februari-2021): #304 Regression bugfix: batch-module needed for sending mails async, basic version should work without
  • v6.4.5 (13-Februari-2021): #303 Bugfix: EML Attachments are modified/have the wrong size
  • v6.4.4 (25-October-2020): #294 Always invoke async success/exception handlers even if set after sending email (behaving more like promises/futures)
  • v6.4.4 (25-October-2020): #291 On Exception only log the email ID at error level and log the whole email at trace level
  • v6.4.4 (25-October-2020): #290 Only perform expensive logging logic if respective logging level is enabled
  • v6.4.3 (6-August-2020): #284 Improved support for Calendar attachments created by gMail
  • v6.4.3 (6-August-2020): #283 Bugfix: Fix support for reading Calendar attachments with quoted-printable transfer-type
  • v6.4.2 (3-August-2020): #281 Bugfix: Fix support for reading Calendar attachments
  • v6.4.1 (26-July-2020): #252 Bugfix: Added missing support for S/MIME enveloped signing
  • v6.4.0 (19-July-2020): #268 Immediately resolve InputStreams when building emails, don't reuse
    • This primarily affects the builder api for S/MIME and DKIM signing / encryption.

v6.3.0 - v6.3.2 (11-July-2020 - 12-July-2020)

v6.2.0 (9-July-2020)

This release adds the following major new feature:

v6.1.0 (5-July-2020)

  • #264 Switch from AssertionError to IllegalStateException
  • Bumped outlook-message-parser from 1.7.3 to 1.7.5
    • bugfix for parsing chinese unsent Outlook messages
    • bugfix Outlook attachments with special characters in the name
  • Bumped email-rfc2822-validator from 2.1.3 to 2.2.0
    • bugfix properly handle brackets in email addresses when allowed
  • Bumped log4j-core from 2.6.1 to 2.13.2

v6.0.2 - v6.0.5 (21-January-2020 - 13-June-2020)

  • #270 Bug: CLI module missing Jetbrains @Nullable annotation dependency needed in runtime
  • #262 Bug: Executor settings passed to the builder are ignored
  • #249 Bug: MimeMessageParser doesn't handle multiple attachments with the same name correctly
  • #245 Bug: JDK9+ Incorrect JPMS Automatic-Module-Name
  • #246 Bug: Sending async emails with and without the Batch module cause lingering threads

v6.0.0-rc1 - v6.0.1 (18-December-2019 - 24-January-2020)

After almost two years of development the next major release 6.0.0 is finally here! And what a doozy it is, with the following major new features:

The core library is now even smaller compared to the 5.x.x series going from 183kb to 134kb!

Here's the complete list of changes:

New features and enhancements

  • #183 To manage all the optional dependencies and related code, Simple Java Mail should be split up into modules
  • #156 Add CLI support
  • #214 Support more advanced batch processing use cases
  • #187 Simple Java Mail should have optional support for signed S/MIME attachments
  • #121 Introduce interfaces for validation and sending, so these steps can be customized
  • #144 Simple Java Mail should tailor the MimeMessage structure to specific needs
  • #138 Add support for Calendar events (iCalendar vEvent)
  • #235 Be able to fix the sent date for a new email
  • #232 Improve encoding of attachment file names
  • #222 Add config property support for trusting hosts and verifying server identity
  • #212 Authenticated proxy server started even if already running, raising exception
  • #207 Implement more comprehensive ThreadPoolExecutor and expose config options
  • #211 SpringSupport should expose the intermediate builder for customization
  • #193 Simple Java Mail should use default server ports when not provided by the user

Bugs solved

  • #242 Renamed log4j2.xml to log4j2_example.xml so it doesn't clash with project config
  • #241 EmailConverter.outlookMsgToEmail duplicates recipients
  • #239 List of Recipients not ordered as added (insertion order not maintained)
  • #236 Message ID should be mapped from Outlook messages as well
  • #210 Connection/session timeout properties not set when not sending in batch mode
  • #201 When parsing Outlook message, FROM address should default to a dummy address when missing
  • #200 When parsing Outlook message, attachment name doesn't fallback on filename if proper name is empty
  • #161 When reading (chinese) .msg files, HTML converted from RTF is completely garbled (encoding issue)
  • #159 Can not parse email with blank email address headers
  • #139 Multiple Bodyparts of same Content-Type not supported for text/html & text/plain within Multipart/mixed or Multipart/alternative
  • #151 Attachment's file extension overwritten by resource's invalid extension

Maintenance updates

  • #165 Move away from Findbugs (unofficial JSR-305) annotations
  • #164 The DKIM dependency has been updated to benefit from the newer Apache V2 license
  • #164 The DKIM dependency has been updated to benefit from the newer Apache V2 license
  • #184 Update JavaMail dependency to 1.6.2, adding support for UTF-8 charset
  • #186 Update JavaMail dependency to 1.6.2, adding support for authenticated HTTP web proxy
  • #146 Added OSGI manifest and switched to spotbugs

Included changes from outlook-message-parser

  • v6.0.1, v1.7.3: #27 When from name/address are not available (unsent emails), these fields are filled with binary garbage
  • v6.0.1, v1.7.2: #26 To email address is not handled properly when name is omitted
  • v6.0.0, v1.7.1: #25 NPE on ClientSubmitTime when original message has not been sent yet
  • v6.0.0, v1.7.1: #23 Bug: _nameid directory should not be parsed (and causing invalid HTML body)
  • v6.0.0, v1.7.0: #18 Upgrade Apache POI 3.9 -> 4.x (but managed back for Simple Java Mail due to incompatibility with Java 7)
  • v6.0.0, v1.6.0: #21 Multiple TO recipients are not handles properly
  • v6.0.0, v1.5.0: #20 CC and BCC recipients are not parsed properly
  • v6.0.0, v1.5.0: #19 Use real Outlook ContentId Attribute to resolve CID Attachments
  • v6.0.0, v1.4.1: #17 Fixed encoding error for UTF-8's Windows legacy name (cp)65001
  • v6.0.0, v1.4.0: #9 Replaced the RFC to HTML converter with a brand new RFC-compliant convert! (thanks to @fadeyev!)
  • v6.0.0, v1.3.0: #14 Dependency problem with Java9+, missing Jakarta Activation Framework
  • v6.0.0, v1.3.0: #13 HTML start tags with extra space not handled correctly
  • v6.0.0, v1.3.0: #11 SimpleRTF2HTMLConverter inserts too many
    tags
  • v6.0.0, v1.3.0: #10 Embedded images with DOS-like names are classified as attachments
  • v6.0.0, v1.3.0: #9 SimpleRTF2HTMLConverter removes some valid tags during conversion
  • v6.0.0, v1.2.1: Ignore non S/MIME related content types when extracting S/MIME metadata
  • v6.0.0, v1.2.1: Added toString and equals methods to the S/MIME data classes
  • v6.0.0, v1.1.21: Upgraded mediatype recognition based on file extension for incomplete attachments
  • v6.0.0, v1.1.21: Added / improved support for public S/MIME meta data
  • v6.0.0, v1.1.20: #7 Fix missing S/MIME header details that are needed to determine the type of S/MIME application
  • v6.0.0, v1.1.19: Log rtf compression error, but otherwise ignore it and keep going and extract what we can.

A big shout out to @dnault (runtime javadoc), @remkop (picocli) and @markenwerk (S/MIME and DKIM) for working with me to make the libraries work with JDK7+ and do what Simple Java Mail needed! Finally a great many thanks the numerous contributors on Simple Java Mail as well as outlook-message-parser - this release would not be there without you.

v5.5.0 - v5.5.1

  • v5.5.1 (20-October-2019): #230 Bugfix: Missing address value in address headers (ie. Return-Path) not handled properly, resulting in Exception
  • v5.5.0 (15-October-2019): #229 Bugfix: Timeouts not working for synchronous sendMail calls.

If you had connection properties configured for non-async send jobs, only now they will actually start to take effect.

v5.4.0 (28-August-2019)

  • #221 API bugfix: server identity verification should not be tied to host trusting
  • #226 Bug fix: Attachments with spaces in name are not handled properly
  • #218 Enhancement: make Email serializable
  • #227 Enhancement: Make parsing recipients from EML file more lenient
  • #225 Enhancement: Clarify dependency on Jakarta Activation: DataSources no longer work on Java 9+

v5.3.0 (16-August-2019)

  • #215 Bug: Current DKIM header canonicalization can lead to invalid DKIM

Note this release should have no impact, but nonetheless is a minor update so you can determine for yourself if this update would cause issues. The release changes DKIM header canonicalization from SIMPLE to RELAXED.

v5.2.1 (16-August-2019)

  • #219 Bug: MimeMessageParser rejects attachments with duplicate names

v5.2.0 (7-July-2019)

  • #213 Update from javax.mail:1.6.0 to jakarta.mail:1.6.3

Note that dependencies that switched as well have been updated as part of this change. This includes the optional DKIM library and the email validation library:

  • net.markenwerk:utils-mail-dkim (1.1.10 -> 1.2.0)
  • com.github.bbottema:emailaddress-rfc2822 (1.1.2 -> 2.1.3)

v5.1.1 - v5.1.7

  • v5.1.7 (22-May-2019): #171 Header validation tripping on known safe emails due to References header
  • v5.1.6 (27-April-2019): #204 A Concurrent exception when an async process starts when the previous connection pool didn't shutdown in time
  • v5.1.6 (27-April-2019): #204 B Exceptions in threads are now caught and logged and don't bubble up anymore. Note that more comprehensive exception handling will be available in 6.0.0 (#148).
  • v5.1.5 (24-April-2019): #202 Fixed ConcurrentModificationException when moving invalid embedded images as regular attachments
  • v5.1.4 (5-April-2019): #163 Fixed missing mimetype for attachments when parsing Outlook messages where mimeTag was not included
  • v5.1.3 (15-Januari-2019): Updated to newer rfc-validator version, which fixed a regression bug in that library
  • v5.1.2 (9-Januari-2019): #189 Bugfix for missing timeout config for .testConnection() function
  • v5.1.1 (22-December-2018): #190 Fix for transitive dependency clash because of emailaddress-rfc2822 library

v5.1.0 (21-November-2018)

v5.0.1 - v5.0.8

  • v5.0.8 (27-Oktober-2018): #178 Fix the annoying vulnerability Github report about spring-core
  • v5.0.7 (27-Oktober-2018): #175 Attachment names are not always parsed properly from MimeMessage
  • v5.0.6 (3-Oktober-2018): #167 Email addresses validated despite cleared validation validation criteria
  • v5.0.5 (3-Oktober-2018): #137 When replying to an email with HTML, the result body is empty
  • v5.0.4 (22-September-2018): #168 Properties aquired through ConfigLoader should be typed explicitly and converted if necessary
  • v5.0.3 (11-April-2018): #136 ServerConfig class should be public API
  • v5.0.2 (7-April-2018): #135 trustingAllHosts should be public on the Builder API
  • v5.0.2 (7-April-2018): #131 NamedDataSource should implement EncodingAware
  • v5.0.1 (10-March-2018): #130 java.lang.ClassNotFoundException: net.markenwerk.utils.mail.dkim.DkimMessage. Solves the issue of missing optional class DKIM even when not used

v5.0.0 (14-Februari-2018)

Also see the migration notes

New features

  • #116 You can now test the connection to the SMTP server
  • #115 Create mailers with a very robust MailerBuilder API, able to ignore defaults as well
  • #114 Create emails with a very robust EmailBuilder API, able to ignore defaults as well. Now includes support for InternetAddress. Also copy emails.
  • #107 You can now easily forward or reply to emails!

Security updates

  • #111 Protocol properties for SMTPS are now applied properly
  • #105 SMTP tries to upgrade to TLS while SMTP_TLS now enforces it and for both SMTP_TLS and SMTPS, mail.smtp.ssl.checkserveridentity is set to true

Maintenance updates

Complete Javadoc overhaul. Navigating the Javadoc should be much more consistent now (builder API being the single public source of truth).

  • #122 The email-rfc2822-validator library has been made a proper Maven dependency (not packaged along anymore)
  • #120 The DKIM library has been made an optional proper Maven dependency (not packaged along anymore)
  • #119 Switched optional Spring dependency version to property and now testing with 4.3.11.RELEASE
  • #113 Updated the underlying JavaMail to 1.6.0

Bugfixes

  • #110 Trusted hosts should be space-delimited
  • #109 Email headers should be allowed to be empty (now conversion errors can occur as well)
  • #103 Converting to MimeMessage results in an invalid Content-Disposition for attachments

v4.4.5 (2-September-2017)

  • #101 API backwards compatibility update, reinstate old addRecipient API as deprecated (sorry for removing it abruptly)

v4.4.4 (23-August-2017)

API usability release. This relase streamlined the recipient setters, breaking backwards compatibility (but straightforward to fix)

v4.3.0 (12-August-2017)

Security and timeout release.

This version safeguards against SMTP injection attack from external values entering the library through Email instance. Also, this release introduces default/configurable timeouts for connecting, reading and writing when sending an email.

  • #89 Support multiple delimited recipient addresses sharing the same TO/CC/BCC name
  • #88 Safeguard subject property (and others) against SMTP CRLF injection attacks
  • #85 Apply configurable timeouts when sending emails
  • #83 Parse INLINE attachments without ID as regular attachments when converting (mostly applicable to Apple emails)

v4.2.3 (21-May-2017)

  • #79: Enhancement: define custom message ID on the Email object

  • #74: v4.2.3-java-6-release: A java6 version with limited capabilities: I've released a customised java6 release with a customised outlook-message-parser 1.1.16-java6-release. This is the last java6 release I will do, as it is simply too much manual labor to create a limited second edition.

    For this edition, I've removed the JDK7 Phaser completely which has the following consequences:

    • If authenticated proxy is used, the bridging proxy server will not be shut down automatically (and might not run the second time)
    • If mails are sent in async mode, the connection pool will not be shut down anymore by itself

    This means your server/application might not stop properly due to lingering processes. To be completely safe, only send emails in sync mode (used by default) and don't use authenticated proxy config.

v4.2.2 (10-May-2017)

  • #73: Patch: fix for sending emails in async mode, which makes sure the connection pool is always closed when the last known email has been sent. Without this fix, the connection pool keeps any parent process running (main thread or Tomcat for example) until a hard kill.

v4.2.1 (12-Feb-2017)

Patch: streamlined convenience methods for adding recipients.

v4.2.0 (12-Feb-2017)

Major feature: Using the EmailConverter you can now convert between Outlook .msg, EML, MimeMessage and Email!

  • #66: Feature: convert email to EML
  • #65: Feature: read outlook messages from .msg file
  • #64: Feature: Added support for logging-only mode that skips the actual sending of emails
  • #63: Feature: Already including in previous patch update: Spring support (read properties from Spring context)
  • #69: Enhancement: Expanded EmailBuilder API to inlude more options for setting (multiple) recipients
  • #70: Enhancement: Most public API now have defensive null-checks for required fields (Fail Fast support)
  • #68: Bugfix: Name should be required for embedded images (added safeguards)
  • #67: Bugfix: Error when name was omitted for attachment
  • minor: added methods on AttachmentResource that reads back the content as (encoded) String
  • other: internal testing is now done using Wiser SMTP test server for testing live sending emails

Note: Starting this release, there will always be a Java6 compatible release as well versioned: "x.y.z-java6-release"

v4.1.3 (28-Jan-2017)

  • #61: Feature: Add support for providing your own Properties object
  • #63: Feature: Spring support (read properties from Spring context)
  • #58: Bugfix: Add support for non-English attachment and embedded image names
  • #62: Bugfix: Empty properties loaded from config should be considered null

NOTE: ConfigLoader moved from /internal/util to /util

v4.1.2 (07-Nov-2016)

  • #52: bug fix for windows / linux disparity when checking socket status
  • #56: bug fix for IOException when signing dkim with a File reference

v4.1.1 (30-Jul-2016)

  • #50: bug fix for manual naming datasources

v4.1.0 (22-Jul-2016)

  • #48: Added programmatic support trusting hosts for SSL connections
  • #47: Honor given names, deduce extension from datasource name, and more robust support for parsing mimemessages

v4.0.0 (05-Jul-2016)

  • #41: added support for fast parallel batch processing
  • #42: added support for config files
  • #43: removed logging implementation dependencies from distribution and documented various sample configs
  • #39: simplified and renamed packages to reflect the domain name of the new website: simplejavamail.org
  • #38: added support for anonymous proxy
  • #38: added support for authenticated proxy

NOTE: All packages have been renamed to "org.simplejavamail.(..)" NOTE: Switched to Java 7

v3.1.1 (11-May-2016)

Major feature: DKIM support!

  • #36: Added proper toString and equals methods for the Email classes
  • #33: Added support for DKIM domain key signing

NOTE: this is the last release still using Java 6. Next release will be using Java 7. /edit: starting with 4.2.0 every release will now have a "x.y.z-java6-release" release as well

v3.0.2 (07-May-2016)

  • #35: added proper .equals() and .toString() methods
  • #34: Fixed bug when disposition is missing (assume it is an attachment)
  • other: added findbugs support internally

v3.0.1 (29-Feb-2016)

  • #31: Fixed EmailAddressCriteria.DEFAULT and clarified Javadoc

v3.0.0 (26-Feb-2016)

  • #30: Improved the demonstration class to include attachments and embedded images
  • #29: The package has been restructured for future maintenance, breaking backwards compatibility
  • #28: Re-added improved email validation facility
  • #22: Added conversion to and from MimeMessage. You can now consume and produce MimeMessage objects with simple-java-mail

v2.5.1 (19-Jan-2016)

  • #25: Added finally clause that will always close socket properly in case of an exception

v2.5 (19-Jan-2016)

  • #24: Updated dependencies SLF4J to 1.7.13 and switched to the updated javax mail package com.sun.mail:javax.mail 1.5.5

v2.4 (12-Aug-2015)

  • #21: builder API uses CC and BCC recipient types incorrectly

v2.3 (21-Jul-2015)

  • #19: supporting custom Session Properties now and emergency access to internal Session object.

v2.2 (09-May-2015)

  • #3: turned off email regex validation by default, with the option to turn it back on
  • #7: fixed NullPointerException when using your own Session instance
  • #10: properly UTF-8 encode recipient addresses
  • #14: switched to SLF4J, so you can easily use your own selected logging framework
  • #17: Added fluent interface for building emails (see here for an example)

v2.1 (09-Aug-2012)

  • fixed character encoding for reply-to, from, to, body text and headers (to UTF-8)
  • fixed bug where Recipient was not public resulting in uncompilable code when calling email.getRecipients()

v2.0 (20-Aug-2011)

  • added support for adding open headers, such as 'X-Priority: 2'

v1.9.1 (08-Aug-2011)

  • updated for Maven support

v1.9 (6-Aug-2011)

  • added support for JavaMail's reply-to address
  • made port optional as to support port defaulting based on protocol
  • added transport strategy default in the createSession method
  • tightened up thrown exceptions (MailException instead of RuntimeException)
  • added and fixed Javadoc

v1.8

  • Added support for TLS (tested with gmail)

v1.7 (22-Mar-2011)

Added support for SSL! (tested with gmail)

  • improved argument validation when creating a Mailer without preconfigured Session instance

known possible issue: SSL self-signed certificates might not work (yet). Please let me know by e-mail or create a new issue

v1.6

Completed migration to Java Simple Mail project.

  • removed all Vesijama references
  • updated TestMail demonstration class for clarification
  • updated readme.txt for test run instructions
  • included log4j.properties

v1.4 (15-Jan-2011)

vX.X (26-Apr-2009)

  • Initial upload to Google Code.

simple-java-mail's People

Contributors

a-brunelliere-maif avatar ajokn avatar amanteaux avatar bbottema avatar blocktrron avatar castortech avatar cbarcenas avatar dependabot[bot] avatar drencrom avatar iweiss avatar jaredjstewart avatar jhult avatar jimpanic avatar juewe avatar kacperfkorban avatar koppor avatar kosinal avatar noguespi avatar norrisjeremy avatar pascalschumacher avatar pmaedel avatar rockymm avatar rohannagar avatar rover886 avatar samuelo avatar triceo avatar vonox7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-java-mail's Issues

Rename package to match domain simplejavamail.org

Now that Simple Java Mail has a proper home (simple-java-mail.org), we should rename the packages and maven groupId to match.

org.codemonkey.simplejavamail -> org.simplejavamail

This should be released as a major release (most likely v4.0.0).

Minor enhancement

This is more a feature enhancement than a bug report.  The library seems 
excellent, but the one thing it doesn't support is the "reply to" option which 
JavaMail does.  Should just be a case of adding

1. a setReplyTo(String replyto) method to Email
2. a getReplyTo() method to Email
3. a check in Mailer to see whether a reply to is set and use it

This can be quite an important flag if using libraries in applications where 
you are sending on behalf of someone else.

Other than that, excellent work.

Original issue reported on code.google.com by [email protected] on 19 Jul 2011 at 9:01

bug on Email.signWithDomainKey(File, String, String)

Email.signWithDomainKey(File, String, String) new FileInputStream(File) and finally close(). ( too good coding habbit! )
This make the class member Email.dkimPrivateKeyInputStream unusable.
Later MimeMessageHelper.signMessageWithDKIM(MimeMessage, Email) new DkimSigner, the closed FileInputStream throws DataFetchException:

org.simplejavamail.mailer.internal.mailsender.MailSenderException: Error signing MimeMessage with DKIM
        at org.simplejavamail.mailer.internal.mailsender.MimeMessageHelper.signMessageWithDKIM(MimeMessageHelper.java:269) ~[simple-java-mail-4.1.1.jar:na]
        at org.simplejavamail.mailer.internal.mailsender.MimeMessageHelper.produceMimeMessage(MimeMessageHelper.java:82) ~[simple-java-mail-4.1.1.jar:na]
        at org.simplejavamail.mailer.internal.mailsender.MailSender.sendMailClosure(MailSender.java:219) ~[bin/:na]
        at org.simplejavamail.mailer.internal.mailsender.MailSender.send(MailSender.java:200) ~[bin/:na]
        at org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:400) ~[bin/:na]
        at org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:391) ~[bin/:na]
        at [...]
Caused by: net.markenwerk.utils.data.fetcher.DataFetchException: Fetch failed after 0 bytes have been copied successully.
        at net.markenwerk.utils.data.fetcher.AbstractBufferedDataFetcher.createException(AbstractBufferedDataFetcher.java:98) ~[bin/:na]
        at net.markenwerk.utils.data.fetcher.AbstractBufferedDataFetcher.doCopy(AbstractBufferedDataFetcher.java:90) ~[bin/:na]
        at net.markenwerk.utils.data.fetcher.AbstractDataFetcher.doCopy(AbstractDataFetcher.java:112) ~[bin/:na]
        at net.markenwerk.utils.data.fetcher.AbstractDataFetcher.copy(AbstractDataFetcher.java:106) ~[bin/:na]
        at net.markenwerk.utils.data.fetcher.AbstractDataFetcher.fetch(AbstractDataFetcher.java:73) ~[bin/:na]
        at net.markenwerk.utils.data.fetcher.AbstractDataFetcher.fetch(AbstractDataFetcher.java:61) ~[bin/:na]
        at net.markenwerk.utils.mail.dkim.DkimSigner.<init>(DkimSigner.java:220) ~[bin/:na]
        at org.simplejavamail.mailer.internal.mailsender.MimeMessageHelper.signMessageWithDKIM(MimeMessageHelper.java:260) ~[simple-java-mail-4.1.1.jar:na]
        ... 8 common frames omitted
Caused by: java.io.IOException: Stream Closed
        at java.io.FileInputStream.readBytes(Native Method) ~[na:1.8.0_91]
        at java.io.FileInputStream.read(FileInputStream.java:233) ~[na:1.8.0_91]
        at net.markenwerk.utils.data.fetcher.AbstractBufferedDataFetcher.doCopy(AbstractBufferedDataFetcher.java:79) ~[bin/:na]
        ... 14 common frames omitted

To fix, and taken I/O expense into account, I suggest to cache the byte[] into static Map<File,byte[]> inside Email.signWithDomainKey(File, String, String): (any security consideration on storing private key?)

class Email {
   static Map<File,byte[]> cachedDomainKeys = new HashMap<>();

public void signWithDomainKey(final File dkimPrivateKeyFile, final String signingDomain, final String selector) {
    [...]
    byte[] bytes = org.apache.commons.io.FileUtils.readFileToByteArray(dkimPrivateKeyFile);
    cachedDomainKeys.put(dkimPrivateKeyFile, bytes);
    dkimPrivateKeyInputStream = new ByteArrayInputStream(bytes);
    [...]

Thanks.

Using .to() .cc() .bcc() from fluent builder API causes duplicated headers

I used the fluent builder API in order to add multiple recipients:

final Email email = new Email.Builder()
        .from(…)
        .subject(…)
        .text(…)
        .to("ONE", "[email protected]")
        .to("TWO", "[email protected]")
        .build();

The email object can be build without problems and gets send. The mail server then rejects the message telling the the header CC occurs more than one time. The recipients need to be a comma separated list value within only one CC header.

This bug also applies to the cc(…) and bcc(…) methods.

I rewrote my code using email.addRecipient(mailBoxName(mailbox), to, TO), then it works as expected.

It would be great to use the fluent API for that also and having a RFC compliant mail composed from it.

NullPointerException in Mailer.sendMail(Email) when the Mailer(Session) constructor is used

When calling

    new org.codemonkey.simplejavamail.Mailer(mySession).sendMail(myEmail);

the following exception occurrs:

    Exception in thread "main" java.lang.NullPointerException
        at org.codemonkey.simplejavamail.Mailer.logSession(Mailer.java:260)
        at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:238)
        at MyClientCode

This is because Mailer.logSession(Session, TransportStrategy) tries to access 
members of the TransportStrategy, which was never initialized by the 
Mailer(Session) constructor.

Original issue reported on code.google.com by [email protected] on 19 Sep 2012 at 6:10

Add support for parallel batch processing

Make sending mails optionally async (threaded)

When sending multiple mails in quick succession, the current process is very slow because every mail being sent has to wait for the previous mail to finish.

There should be an option to do it asynchronously using new threads.

Proxy socket closed when connecting to authenticated proxy

I use proxy and after finish email was sending, however show exception like this.

Exception in thread "Thread-5" org.simplejavamail.mailer.internal.socks.common.SocksException: server crashed...
    at org.simplejavamail.mailer.internal.socks.socks5server.AnonymousSocks5Server.checkIoException(AnonymousSocks5Server.java:91)
    at org.simplejavamail.mailer.internal.socks.socks5server.AnonymousSocks5Server.run(AnonymousSocks5Server.java:76)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: Socket closed
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
    at java.net.ServerSocket.implAccept(ServerSocket.java:545)
    at java.net.ServerSocket.accept(ServerSocket.java:513)
    at org.simplejavamail.mailer.internal.socks.socks5server.AnonymousSocks5Server.run(AnonymousSocks5Server.java:72)
    ... 1 more

Simple email sending doesn't work

What steps will reproduce the problem?
1. Just trying to implement the example that you provided in the wiki

What is the expected output?
Nothing just email has to be sent...

What do you see instead?
See here: http://pastebin.com/t58fWEpG

What version of the product are you using? On what operating system?
Latest

Please provide any additional information below.
Trying to send email with gmail. Added your libraries and code compiles OK. I'm 
using Eclipse on Xubuntu 11.10.

Original issue reported on code.google.com by [email protected] on 31 Jul 2012 at 3:28

Update SLF4J and JavaMail dependencies

The groupId for JavaMail changed, see this stackoverflow answer from the lead developer of JavaMail.
So the new maven coordinates right now are:

<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
    <version>1.5.5</version>
</dependency>

The SLF4J dependency also got a bit stale, the most recent version right now is:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.13</version>
</dependency>

Thanks a lot for this library, it really makes my life easier. :)

Javadoc regarding default setting for email validation contradicting code, which is correct?

8370db1#commitcomment-16375443

The following javadoc and code show what the default email validation strictness is set to:

    /**
     * The default setting is not strictly 2822 compliant. For example, it does not include the {@link #ALLOW_DOMAIN_LITERALS} criteria, which results in
     * exclusions on single domains.
     * <p>
     * Included in the defaults are: <ul> <li>{@link #ALLOW_QUOTED_IDENTIFIERS}</li> <li>{@link #ALLOW_PARENS_IN_LOCALPART}</li> </ul>
     */
    public static final EnumSet<EmailAddressCriteria> DEFAULT = of(ALLOW_DOMAIN_LITERALS);

However, I'm not sure what actually should be the default. Do we even need a default? What is its purpose?

Initially I thought a more strict-than-RFC-compliant default would be needed to make sure main stream services and servers can handle the more mundane email strings, rather than the exotic strings the RFC would allow.

What should be the default?

Restructure files

Now that simple-java-mail is growing a bit, the single package that holds everything is becoming a little messy. A simple util package and perhaps an email should be enough to separate the essentials from the rest.

Catastrophic backtracking in validation regexes

There are some email addresses that behave *very* poorly with the validation 
done in EmailValidationUtil.  I think it might be due to the nested quantifiers 
in the complex regexes there.  They literally take hours to finish the 
validation, using 100% CPU.

Is there any way to fix this, and barring that, can an option be added to skip 
validation?

To reproduce:
1. Try to send an email to an address like 
[email protected]
2. Wait for computer to explode

(Using java 1.6.0_31)

Original issue reported on code.google.com by [email protected] on 20 Apr 2012 at 10:13

SimpleMail not working with Gmail

I have a GMail account and am trying to use GMail to send emails for my simple app:

// Groovy pseudo-code
static void main(String[] args) {
    Email email = new Email()
    email.setFromAddress("Me Myself", "[email protected]");
    email.setSubject("hey!!");
    email.addRecipient("Some One", "[email protected]", RecipientType.TO);
    email.setText("We should meet up! ;)");

    Mailer mailer = new Mailer('smtp.gmail.com', 587, "[email protected]", "mygmail+password",
        TransportStrategy.SMTP_TLS)
    Properties props = new Properties()
    props.put('mail.smtp.auth', 'true')
    props.put('mail.smtp.starttls.enable', 'true')
    mailer.applyProperties(props)

    mailer.sendMail(email)
}

Produces:

<large stack trace omitted for brevity>
Caught: org.codemonkey.simplejavamail.MailException: Generic error: null
org.codemonkey.simplejavamail.MailException: Generic error: null
    at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:269)
    at org.codemonkey.simplejavamail.Mailer$sendMail$0.call(Unknown Source)
    at com.me.myapp.Driver.main(Driver.groovy:38)
Caused by: javax.mail.AuthenticationFailedException
    at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:261)
    ... 2 more

I've confirmed that my username/password are my correct gmail logins. Any thoughts here?

Add access to the underlying javax.mail.Session properties

I had a case where the connection to the smtp server was hanging and never returning. It seems to be linked to the fact no value for the timeout parameters was is given when building the session. The parameters are mail.smtp.timeout and mail.smtp.connectiontimeout and there is currently no easy way to set these.

One option is to use the Mailer constructor with the Session argument, but then it fails on a NPE in logSession because the transportStrategy is not set. Also, a lot of the setup work has to be redone using this approach.

I think a better approach, would be to provide another arguments to the Mailer constructor, adding a Properties argument which would allow for full customisation of the session properties.

Possible in an Android Project?

Hi,
I'm trying to use this in my Android project but so far no luck. I was previously using "com.sun.mail:android-*:1.5.5" which worked but not so well with Gmail's SMTP and that's why I'm trying Simple Java Mail now.
During build I get these warnings:

`warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.DataHandler$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.

warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.

warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.

warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.

warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$4) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.

warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$5) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class.
`

The app runs fine until I get to the part of sending the actual mail:
java.lang.NoClassDefFoundError: javax.activation.DataHandler at javax.mail.internet.MimeBodyPart.setContent(MimeBodyPart.java:789) at org.codemonkey.simplejavamail.Mailer$MimeEmailMessageWrapper.<init>(Mailer.java:549) at org.codemonkey.simplejavamail.Mailer.produceMimeMessage(Mailer.java:335) at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:239) at xx.xx.xx.MailJob$1.doInBackground(MailJob.java:142)

and in that line I have new Mailer(host, port, user, pass, TransportStrategy.SMTP_TLS).sendMail(email);

Any input would be helpful.

Replace LOG4J with SLF4J + LOG4J

SLF4J is an interface which supports other logging frameworks and we can provide LOG4J as a default and let users override this choice for their own needs.

Access to headers and flags...

One other thing which I spotted which aren't catered for by SimpleJavaMail but 
are by the Javamail API.

Headers
-------
Personally, I hate them, but clients are always asking if you can set the 
"important" flag on emails.  This is normally done by setting custom headers 
such as X-Priority and Importance.  To do this, javamail provides 
message.setHeader(String,String).  Would be good to be able to do this in 
simplejavamail

I'm now using simplejavamail "in anger" (although still in a testing phase) so 
I may well suggest some other enhancements as I find them.

As I said last time, great work...much easier than the javamail api.

Tom

Original issue reported on code.google.com by [email protected] on 18 Aug 2011 at 4:31

Email attachments are not correctly encoded (the names)?

What steps will reproduce the problem?
1. Attach a file with åäö characters in them (like image)
2. Recieve the email and see åäö is now incorrectly encoded.
3.

What is the expected output? What do you see instead?
The file attached with correct name. The file attached with swedish characters 
garbled


What version of the product are you using? On what operating system?
2.1


Please provide any additional information below.
I did a quick google and mail attachmanet names needed to be encoded correctly. 
And I wonder if this is lacking.

Original issue reported on code.google.com by [email protected] on 23 Jul 2013 at 11:06

Add support for Proxy (HTTP, SOCKS, authenticated)

JavaMail only supports anonymous SOCKS proxy.

The only way to add this capability is by incorporating a SOCKS server into Simple Java Mail: it would be started when an email is being sent through Mailer.sendMail() and accepts the anonymous proxy connection from JavaMail on localhost and relays it to a proper proxy by also including a proxy client in Simple Java Mail which can connect to any proxy (HTTP, SOCKS, anonymous and authenticated).

So:

Mailer.sendMail() -> JavaMail Transport.send() (supports only anonymous SOCKS) -> Simple Java Mail temp proxy (anonymous SOCKS) -> Simple Java Mail proxy client -> the real proxy through which you want to go (HTTP, SOCKS, anonymous and authenticated)


But I don't want to balloon this library into the megabytes, because some open source proxy library included guava and netty and whatnot. Simple Java Mail is to remain a sleak library that includes everything in itself (by using the maven shade plugin).

Email Validator

Version: 2.1

Issue: The Email validation goes into an infinite loop while trying to build the pattern matcher for the following email address: ewiuhdghiufduhdvjhbajbkerwukhgjhvxbhvbsejskuadukfhgskjebf@gmail.net (Obviously a random test case but, the behavior is surprising)

Trace: EmailValidationUtil line: 55

Version: 3.0 worked (this maybe due to the default behavior to skip the validator)

Document thread-safety gurantees of Mailer

Is it recommended to create and share a single instance of Mailer between multiple threads after all configuration on it is done?

All the examples on the home page create a new Mailer instance and then (presumably) throw it away.

It just feels like one of those configure-once-and-use-it-everywhere objects like Jacksons ObjectMapper or a database connection pool. I assume that other developers will think the same, so it might be nice to have it spelled out somewhere (JavaDoc and/or Examples).

I haven't measured the overhead of creating a new Mailer for every E-Mail though, so it might as well be premature optimization.

Microsoft Exchange Server

Can we send mails using microsoft exchange server, if yes, please suggest a sample. thanks Aravind

URLDataSource uses source data name

When adding at attachment from a URL source (e.g. a pdf on S3) the name of the attachment is not honored. Instead of the specified name, the file name of the resource is used. The workaround is simple - wrap using a named datasource. Something simple like the following worked for me,

private static final class NamedDataSource implements DataSource {
  private final DataSource delegate;
  private final String name;

  NamedDataSource(String name, DataSource delegate) {
    this.delegate = requireNonNull(delegate);
    this.name = requireNonNull(name);
  }

  @Override public String getName() {
    return name;
  }
  @Override public String getContentType() {
    return delegate.getContentType();
  }
  @Override public InputStream getInputStream() throws IOException {
    return delegate.getInputStream();
  }
  @Override public OutputStream getOutputStream() throws IOException {
    return delegate.getOutputStream();
  }
}

Need to document developer logging

Need to document developer logging options, system properties, 
logging.properties, etc.

I could find no information on this on your page.  If there, please provide a 
link...

Thanks,
Jeff

Original issue reported on code.google.com by [email protected] on 2 Nov 2012 at 12:07

log4j configuration is being supplied with the library

Currently a configuration file for log4j2 is provided at:

./src/main/resources/log4j2.xml

This file is packaged up and bundled with the rest of the library. That means that any project that uses this application will have that log4j2.xml config file in their classpath.

Since most applications will want to provide their own logging implementations and configuration, it doesn't make sense for a library to be providing the log4j2.xml config file.

This problem is also present for an older version of simple-java-mail that included log4j.properties. This overrode the sandboxed log4j configuration that was provided by the system that ran my application if I was running from a debugger.

This stackoverflow post talks about this issue in the comments:

http://stackoverflow.com/a/5081386/622115

Thanks,

James

DKIM: bug on reading DNS TXT for DKIM long public key?

Hi I am newbie to GitHub.
SimpleJavaMail ported markenwerk/java-utils-mail-dkim, nice and thanks.
However I am not sure where I should post this issue, since markenwerk/java-utils-mail-dkim has no tab for "issue" and simple-java-mail is active here.
Anyway, while testing DKIM signing feature, I got the exception:

Obtaining the domain key for hubble.makedifferent.net.m failed
net.markenwerk.utils.mail.dkim.DkimSigningException: Obtaining the domain key for hubble.makedifferent.net.m failed
        at net.markenwerk.utils.mail.dkim.DkimSigner.sign(DkimSigner.java:442) ~[bin/:na]
        [...]
Caused by: java.io.IOException: net.markenwerk.utils.mail.dkim.DkimException: The public key MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB couldn't be read.
        at net.markenwerk.utils.mail.dkim.DkimSigningException.<init>(DkimSigningException.java:77) ~[bin/:na]
        ... 6 common frames omitted
Caused by: net.markenwerk.utils.mail.dkim.DkimException: The public key MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB couldn't be read.
        at net.markenwerk.utils.mail.dkim.DomainKey.getPublicKey(DomainKey.java:144) ~[bin/:na]
        [...]
Exception in thread "main" org.codemonkey.simplejavamail.MailException: Third party error: Obtaining the domain key for hubble.makedifferent.net.m failed
        at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:257)
        [...]
Caused by: net.markenwerk.utils.mail.dkim.DkimSigningException: Obtaining the domain key for hubble.makedifferent.net.m failed;
  nested exception is:
        java.io.IOException: net.markenwerk.utils.mail.dkim.DkimException: The public key MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB couldn't be read.
        at net.markenwerk.utils.mail.dkim.DkimSigner.sign(DkimSigner.java:442)
        [...]
Caused by: java.io.IOException: net.markenwerk.utils.mail.dkim.DkimException: The public key MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB couldn't be read.
        at net.markenwerk.utils.mail.dkim.DkimSigningException.<init>(DkimSigningException.java:77)
        ... 6 more
Caused by: net.markenwerk.utils.mail.dkim.DkimException: The public key MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB couldn't be read.
        at net.markenwerk.utils.mail.dkim.DomainKey.getPublicKey(DomainKey.java:144)
        [...]

Checking my DKIM public key:

> dig m._domainkey.hubble.makedifferent.net TXT
;; ANSWER SECTION:
m._domainkey.hubble.makedifferent.net. 13888 IN TXT "v=DKIM1\; k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" "CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB"

However in DomainKeyUtil.getValue(String) it retrieved as:

"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQw4AU7D/BKYINWOJJCjZ5OJJ7FzeuWU/B001/1yvxwtAvd/cuH3fRbWT0DUu49T+4igPwlCFnDkCkYvnY5otUPCGE8" CYOE6gx5FId0vX1X+CfEAcpqQZhTXr1kUUH6rbT6oiTAnGvkFhPP5PUICU6P9wZ0WJocsrkCVPYgXrQJQIDAQAB

I supposed it was due to multiple lines of TXT (DKIM) record:
https://help.directadmin.com/item.php?id=552

Therefore I made an override after String value = (String) txtRecord.get();

            String value = (String) txtRecord.get();
            if (null == value) {
                throw new DkimException("Value of RR " + recordName + " couldn't be retrieved");
            }
            value = bugfixMultipleLinesTxt(value);

    private static String bugfixMultipleLinesTxt(String value) {
        if (value.endsWith("\""))
            return value;

        if (value.startsWith("\"")) {
            value = value.substring(1);
        }
        int p = value.indexOf("\" ");
        while (p != -1) {
            value = value.substring(0, p) + value.substring(p + 2);
            p = value.indexOf("\" ");
        }
        return value;
    }

Then it works. Signature verified pass by Gmail Yahoo Microsoft.
Hardly believe that Attributes attributes = dnsContext.getAttributes(recordName, new String[] { "TXT" }); comes from javax.naming.directory.DirContext.getAttributes(String, String[])
Did I misunderstand anything?

Unicode in local part of email address fails

What steps will reproduce the problem?
1. Try to send email to å[email protected]

What is the expected output? What do you see instead?
Email should send according to http://tools.ietf.org/html/rfc6531

Instead i get: Get this error Could not send email. Inner error: Invalid TO 
address: org.codemonkey.simplejavamail.Email@60e6e627

What version of the product are you using? On what operating system?
I use 2.1 on windows

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 2 Sep 2014 at 9:47

Simple Java Mail from MimeMessage

I would need to handle files saved in .eml format, easily convertible into MimeMessage. It would be great to build SimpleMail from MimeMessage!
Thanks a lot!

Would be nice to add mock junit testing support

It would be nice to add a feature that performs all sorts of validations on the 
email, but stops short from actually delivering the email over the network.  
For unit testing purposes, etc.

Original issue reported on code.google.com by [email protected] on 12 Jul 2012 at 1:50

High CPU usage & geometrically increasing delay with increasing length of the recipient address

Measured with simple-java-mail-v2.1 and javax.mail-1.5.1

05-05-2015 16:53:48: Sending email: [email protected] -> [email protected] (3 attachments)
05-05-2015 16:53:48: These attachments were sent:
05-05-2015 16:53:48: Attachment 1 / 3 filename '108782_-_Sally-Ellen_Example.pdf', content type 'application/pdf'
05-05-2015 16:53:48: Attachment 2 / 3 filename '108782_Sally-Ellen_Example_108782_-_Ansioluetteloni.pdf', content type 'application/pdf'
05-05-2015 16:53:48: Attachment 3 / 3 filename '108782_Sally-Ellen_Example_108782_-_Hakemuskirje.pdf', content type 'application/pdf'
05-05-2015 16:55:57: DEBUG Mailer - starting mail session (host: null, port: null, username: null, authenticate: null, transport: SMTP_PLAIN)

05-05-2015 16:57:31: Sending email: [email protected] -> [email protected] (3 attachments)
05-05-2015 16:57:31: These attachments were sent:
05-05-2015 16:57:31: Attachment 1 / 3 filename '108782_-_Sally-Ellen_Example.pdf', content type 'application/pdf'
05-05-2015 16:57:31: Attachment 2 / 3 filename '108782_Sally-Ellen_Example_108782_-_Ansioluetteloni.pdf', content type 'application/pdf'
05-05-2015 16:57:31: Attachment 3 / 3 filename '108782_Sally-Ellen_Example_108782_-_Hakemuskirje.pdf', content type 'application/pdf'
05-05-2015 17:01:20: DEBUG Mailer - starting mail session (host: null, port: null, username: null, authenticate: null, transport: SMTP_PLAIN)

05-05-2015 17:16:47: Sending email: [email protected] -> [email protected] (3 attachments)
05-05-2015 17:16:47: These attachments were sent:
05-05-2015 17:16:47: Attachment 1 / 3 filename '108782_-_Sally-Ellen_Example.pdf', content type 'application/pdf'
05-05-2015 17:16:47: Attachment 2 / 3 filename '108782_Sally-Ellen_Example_108782_-_Ansioluetteloni.pdf', content type 'application/pdf'
05-05-2015 17:16:47: Attachment 3 / 3 filename '108782_Sally-Ellen_Example_108782_-_Hakemuskirje.pdf', content type 'application/pdf'
05-05-2015 17:25:24: DEBUG Mailer - starting mail session (host: null, port: null, username: null, authenticate: null, transport: SMTP_PLAIN)

Summary

Email address Addr. Length Start (hh:mm:ss) Finish (hh:mm:ss) Time taken Delta
[email protected] 48 16:53:48 16:55:57 0:02:09 n/a
[email protected] 49 16:57:31 17:01:20 0:03:49 0:01:40
[email protected] 50 17:16:47 17:25:24 0:08:37 0:04:48
[email protected] 51 DID NOT MEASURE -- This is the address that brought this problem to attention

I haven't verified with plain Java Mail if the problem persists.

Internal code structure compromises integrity

Previous restructuring improved the logical folder structure, but package-technically compromised on integrity. That is to say, because of the way Java works with packages, some API had to be exposed to the public as the classes don't share the same folder anymore.

Case in point: the MessageException, which contains the message templates either has to be made public, or exceptions thrown by Email have to manage its own templates. This is messy.

We need a middle road here.

Add support for config files

Add support for config files, so that the SMTP and proxy server details can be configured there as well as a default subject, cc. bcc, from-address and reply-to-address.

Make the config path configurable, so that you can have different configuration files per environment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.