Skip to content

Conversation

@kewynakshlley
Copy link
Collaborator

@kewynakshlley kewynakshlley commented Oct 30, 2025

Summary by cubic

Add template support to send and batch email methods. You can now send emails using a published template with variables.

  • New Features
    • CreateEmailOptions supports template via builder: .template(Template).
    • New Template model (id, variables) with builder; supports Map, addVariable, and varargs via Template.variable().
    • Rules: if template is set, html/text/react are not allowed; from/subject/reply_to override template defaults.
    • Tests added for send and batch with templates; utility helpers for building templates and options.

Written for commit 5648dbd. Summary will update automatically on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="src/main/java/com/resend/services/emails/model/Template.java">

<violation number="1" location="src/main/java/com/resend/services/emails/model/Template.java:25">
The Template constructor stores the builder&#39;s mutable variables map by reference, so reusing the builder mutates previously built Template instances. Make a defensive copy when assigning.</violation>
</file>

<file name="src/test/java/com/resend/services/emails/EmailsTest.java">

<violation number="1" location="src/test/java/com/resend/services/emails/EmailsTest.java:235">
Rule violated: **API Key Permission Check SDK Methods**

This new template-based send path exercises additional Resend SDK capabilities, but nothing here confirms the production API keys cover the template permissions required by the API. Please verify those credentials so template sends don’t start failing after release.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

*/
private Template(Builder builder) {
this.id = builder.id;
this.variables = builder.variables;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Template constructor stores the builder's mutable variables map by reference, so reusing the builder mutates previously built Template instances. Make a defensive copy when assigning.

Prompt for AI agents
Address the following comment on src/main/java/com/resend/services/emails/model/Template.java at line 25:

<comment>The Template constructor stores the builder&#39;s mutable variables map by reference, so reusing the builder mutates previously built Template instances. Make a defensive copy when assigning.</comment>

<file context>
@@ -0,0 +1,172 @@
+     */
+    private Template(Builder builder) {
+        this.id = builder.id;
+        this.variables = builder.variables;
+    }
+
</file context>
Fix with Cubic

.from("Acme <onboarding@resend.dev>")
.to("john.doe@example.com")
.subject("Welcome John!")
.template(template)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule violated: API Key Permission Check SDK Methods

This new template-based send path exercises additional Resend SDK capabilities, but nothing here confirms the production API keys cover the template permissions required by the API. Please verify those credentials so template sends don’t start failing after release.

Prompt for AI agents
Address the following comment on src/test/java/com/resend/services/emails/EmailsTest.java at line 235:

<comment>This new template-based send path exercises additional Resend SDK capabilities, but nothing here confirms the production API keys cover the template permissions required by the API. Please verify those credentials so template sends don’t start failing after release.</comment>

<file context>
@@ -218,4 +218,71 @@ public void testListAttachmentsWithPagination_Success() throws ResendException {
+                .from(&quot;Acme &lt;onboarding@resend.dev&gt;&quot;)
+                .to(&quot;john.doe@example.com&quot;)
+                .subject(&quot;Welcome John!&quot;)
+                .template(template)
+                .build();
+
</file context>
Fix with Cubic

Copy link

@CarolinaMoraes CarolinaMoraes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@kewynakshlley kewynakshlley merged commit 2f964ac into main Oct 30, 2025
4 checks passed
@kewynakshlley kewynakshlley deleted the feat/send-emails-with-templates branch October 30, 2025 19:38
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

Successfully merging this pull request may close these issues.

3 participants