From a2f9ea715c78c9e268e04c9be24a3506ee9ba9ef Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 14 Aug 2025 17:41:03 +0300 Subject: [PATCH 1/2] support cid for inline images --- lib/resend/emails/attachment.ex | 4 +++- lib/resend/swoosh/adapter.ex | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/resend/emails/attachment.ex b/lib/resend/emails/attachment.ex index 181e04a..fbc0a6b 100644 --- a/lib/resend/emails/attachment.ex +++ b/lib/resend/emails/attachment.ex @@ -11,6 +11,7 @@ defmodule Resend.Emails.Attachment do :content, :content_type, :filename, + :inline_content_id, path: "" ] @@ -20,7 +21,8 @@ defmodule Resend.Emails.Attachment do content: map["content"], content_type: map["content_type"], filename: map["filename"], - path: map["path"] + path: map["path"], + inline_content_id: map["inline_content_id"] } end end diff --git a/lib/resend/swoosh/adapter.ex b/lib/resend/swoosh/adapter.ex index 4e8700a..136a581 100644 --- a/lib/resend/swoosh/adapter.ex +++ b/lib/resend/swoosh/adapter.ex @@ -71,7 +71,8 @@ defmodule Resend.Swoosh.Adapter do %Resend.Emails.Attachment{ content: Swoosh.Attachment.get_content(attachment, :base64), content_type: attachment.content_type, - filename: attachment.filename + filename: attachment.filename, + inline_content_id: attachment.filename } end From 77d5b0b4ef1371f4a8c25307322f47210c267b0f Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 14 Aug 2025 17:44:20 +0300 Subject: [PATCH 2/2] support custom cid from swoosh --- lib/resend/swoosh/adapter.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/resend/swoosh/adapter.ex b/lib/resend/swoosh/adapter.ex index 136a581..f20471d 100644 --- a/lib/resend/swoosh/adapter.ex +++ b/lib/resend/swoosh/adapter.ex @@ -68,11 +68,13 @@ defmodule Resend.Swoosh.Adapter do end defp format_attachment(%Swoosh.Attachment{} = attachment) do + cid = if is_nil(attachment.cid), do: attachment.filename, else: attachment.cid + %Resend.Emails.Attachment{ content: Swoosh.Attachment.get_content(attachment, :base64), content_type: attachment.content_type, filename: attachment.filename, - inline_content_id: attachment.filename + inline_content_id: cid } end