components-contrib icon indicating copy to clipboard operation
components-contrib copied to clipboard

Add Attachments option in SMTP binding. It will allow send mail attachments

Open geffzhang opened this issue 3 years ago • 14 comments

Describe the feature

Add Attachments option in SMTP binding. It will allow send mail attachments

RELEASE NOTE:

geffzhang avatar Aug 09 '21 08:08 geffzhang

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.

dapr-bot avatar Sep 08 '21 08:09 dapr-bot

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.

dapr-bot avatar Sep 15 '21 08:09 dapr-bot

Reopened this.

yaron2 avatar Oct 25 '21 17:10 yaron2

Came across a need for this recently. Is there any guidance on how this should look for the API?

rovangju avatar Oct 17 '22 21:10 rovangju

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.

yaron2 avatar Oct 18 '22 14:10 yaron2

/assign

robertojrojas avatar Dec 15 '22 22:12 robertojrojas

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 the request.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.

robertojrojas avatar Dec 16 '22 18:12 robertojrojas

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.

yaron2 avatar Dec 16 '22 18:12 yaron2

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.

robertojrojas avatar Dec 19 '22 17:12 robertojrojas

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).

rovangju avatar Dec 19 '22 18:12 rovangju

The topic of multipart is a great point! Let's look into that.

robertojrojas avatar Dec 19 '22 22:12 robertojrojas

@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
  ]
}

berndverst avatar Feb 01 '23 22:02 berndverst

Hello, @artursouza Is there any estimated time that feature will be available?

KrzysztofPajak avatar Jul 12 '23 04:07 KrzysztofPajak

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?

libreo-abrettschneider avatar Jan 16 '24 14:01 libreo-abrettschneider