components-contrib
components-contrib copied to clipboard
Add Attachments option in SMTP binding. It will allow send mail attachments
Describe the feature
Add Attachments option in SMTP binding. It will allow send mail attachments
RELEASE NOTE:
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.
Reopened this.
Came across a need for this recently. Is there any guidance on how this should look for the API?
Came across a need for this recently. Is there any guidance on how this should look for the API?
As an output binding, the attachment can use the data
property on the payload. The binding will then check if the request.Data property is not nil, and then use that as the attachment.
/assign
It appears that the request.Data
is already being used for the body of the email.
I wonder if it makes sense to do the following instead:
- If the contents of the
request.Data
is preferred to be placed as an attachment instead of being added to the body, we could add another metadata property, say something like bodyAsAttachment. The SMTP binding code can use this property as a flag to decide if it places therequest.Data
as the email attachment or if missing place it in the body of the email (as it currently does). - If the attachment flag (bodyAsAttachment) is set, the body could be a simple text like "See attachment" or the like.
- A limit to the size of the attachment can be applied, say 10MB-20MB, can be set to avoid rejection of the email by the SMTP servers.
If the contents of the request.Data is preferred to be placed as an attachment instead of being added to the body, we could add another metadata property, say something like bodyAsAttachment. The SMTP binding code can use this property as a flag to decide if it places the request.Data as the email attachment or if missing place it in the body of the email (as it currently does).
This makes sense. No need to add a "See attachment" to the body in the case of attachment.
Came across a need for this recently. Is there any guidance on how this should look for the API?
@rovangju Could you please share the specifics on the need for attachments? It'll help me have a better idea how folks are thinking about using this feature.
Nothing special; simple things like generated results from a job (pdf, csv, etc). One thing I was wondering was if there was a way to detect if the data was multipart. Then you could use existing builders to craft whatever payloads you want (e.g.: embedded logo images, etc).
The topic of multipart is a great point! Let's look into that.
@robertojrojas If the body is multipart we should pass it through as is (not sure if our library supports defining the raw message like that). Can use this to detect: https://pkg.go.dev/mime/multipart should be good for trying to parse the body as multipart.
But for users who want more convenience and do not know how to craft multipart encodings.. I think we should support some sort of option like this (JSON):
{
"body": "sometext",
"attachments": [
{
"content-type": "bla",
"filename": "stuff",
"data": "b64 encoded file contents"
},
// more attachments here
]
}
Hello, @artursouza Is there any estimated time that feature will be available?
We also need to send attachments via mail. Cause this feature is missing we have to implement smtp in the app itself which is what dapr is trying to avoid. In our case we need to send reports as attachments. Still no solution for that I assume?