Skip to content

Feature Request : Sending attachments via Stream #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kiwisincebirth opened this issue Sep 29, 2022 · 3 comments
Closed

Feature Request : Sending attachments via Stream #11

kiwisincebirth opened this issue Sep 29, 2022 · 3 comments

Comments

@kiwisincebirth
Copy link

kiwisincebirth commented Sep 29, 2022

Current State

The current API for creating a mail message with email attachments i.e.

// usage example (except) from documentation
Message message = Message.builder().attachment(ATTACHMENT_1)

// the builder method signatures
public Message.MessageBuilder attachment(File attachment)
public Message.MessageBuilder attachment(List<File> attachments)

The API utilises The java.io.File class to indicate the resource to be included / attached to the email. From the File java doc An abstract representation of file and directory pathnames. - Which means the API will only work for attachments, that are stored as files in a file filesystem.

Issue

In a server side application data (files) is generally not stored in a file system. It can be stored in a database or in another location or service. In my scenario the attachment is downloaded from a private web service via HTTPS.

To use the API I have to download the attachment and store it in as a local file system. This creates several issues based a double handling writing to and reading from the file system, performance, latency, resource use, etc

Enhancement

Like most modern programming languages Java support the concept of a stream data from a producer to consumer. This is in the form of the InputStream and OutputStream api's.

Ideally MessageBuilder should be enhanced to support streaming of attachments, which vastly improves the flexibility for providing attachment data.

@szagr
Copy link
Collaborator

szagr commented Sep 29, 2022

@kiwisincebirth, thank you for raising this topic.
Support streaming of attachments will be added in the next release.

@szagr
Copy link
Collaborator

szagr commented Oct 9, 2022

In v1.0.5 was added FormData support.
Example:
https://github.com/mailgun/mailgun-java/blob/main/src/test/java/com/mailgun/integration/MailgunMessagesIntegrationTest.java#L212
Currently, only one FormData can be used.
Multiple FormData support may be implemented later
OpenFeign/feign-form#91
Or we can implement some workaround ourselves.

@szagr szagr closed this as completed Oct 9, 2022
@szagr
Copy link
Collaborator

szagr commented Nov 8, 2022

@kiwisincebirth Multiple FormData attachment support was added in v1.0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants