Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
jamesfredley merged PR #524: URL: https://github.com/apache/grails-static-website/pull/524 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
jamesfredley commented on code in PR #524:
URL:
https://github.com/apache/grails-static-website/pull/524#discussion_r3640719109
##
guides/grails-email/v8/snippets/grails-app/controllers/example/MailController.groovy:
##
@@ -0,0 +1,25 @@
+package example
+
+import groovy.transform.CompileStatic
+import groovy.util.logging.Slf4j
+
+import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY
+
+@Slf4j
+@CompileStatic
+class MailController {
+
+EmailService emailService
+
+static allowedMethods = [send: 'POST']
+
+def send(EmailCmd cmd) {
+if (cmd.hasErrors()) {
+respond cmd.errors, view: '/application/errors', status:
UNPROCESSABLE_ENTITY
+return
+}
+log.info '{}', cmd.toString()
Review Comment:
The guide still publishes `cmd.toString()` at INFO, which includes
recipient, CC/BCC, subject, and both message bodies. Please re-vendor the final
privacy-safe controller from the companion app after its logging fix is
complete.
##
guides/grails-email/v8/snippets/src/main/groovy/example/AwsSesEmailService.groovy:
##
@@ -0,0 +1,84 @@
+package example
+
+import grails.config.Config
+import grails.core.support.GrailsConfigurationAware
+import groovy.transform.CompileStatic
+import groovy.util.logging.Slf4j
+import software.amazon.awssdk.regions.Region
+import software.amazon.awssdk.services.ses.SesClient
+import software.amazon.awssdk.services.ses.model.Body
+import software.amazon.awssdk.services.ses.model.Content
+import software.amazon.awssdk.services.ses.model.Destination
+import software.amazon.awssdk.services.ses.model.Message
+import software.amazon.awssdk.services.ses.model.SendEmailRequest
+import software.amazon.awssdk.services.ses.model.SendEmailResponse
+
+@Slf4j
+@CompileStatic
+class AwsSesEmailService implements EmailService, GrailsConfigurationAware {
// <1>
+
+String sourceEmail
+SesClient sesClient
+
+@Override
+void setConfiguration(Config co) {
+String awsRegion = co.getProperty('aws.ses.region', String)
+if (!awsRegion) {
+throw new IllegalStateException('aws.ses.region not set')
+}
+this.sesClient =
SesClient.builder().region(Region.of(awsRegion)).build()
+
+this.sourceEmail = co.getProperty('aws.ses.source', String, '')
Review Comment:
This snippet is still the pre-`b07505d` implementation: it warns and
continues when `aws.ses.source` is missing, and `bodyOfEmail` still drops the
text alternative whenever HTML is present. Please re-vendor the final companion
implementation after the sample PR is green; it must fail fast on missing
source and preserve both text and HTML.
##
guides/grails-email/v8/snippets/src/integration-test/groovy/example/MailControllerSpec.groovy:
##
@@ -0,0 +1,108 @@
+package example
+
+import grails.testing.mixin.integration.Integration
+import groovy.json.JsonSlurper
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.TestConfiguration
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Primary
+import org.springframework.http.HttpStatus
+import org.springframework.http.ResponseEntity
+import org.springframework.web.client.HttpClientErrorException
+import org.springframework.web.client.RestTemplate
+import spock.lang.Specification
+import spock.mock.DetachedMockFactory
+
+@Integration
+class MailControllerSpec extends Specification {
+
+@Autowired
+EmailService emailService
+
+void '/mail/send invokes email service with expected message'() {
+when:
+RestTemplate client = new RestTemplate()
+ResponseEntity resp = client.postForEntity(
+"http://localhost:$serverPort/mail/send";,
+[
+subject : 'Test',
+recipient: '[email protected]',
+textBody : 'Hola hola'
+],
+Map
+)
+
+then:
+resp.statusCode == HttpStatus.OK
+1 * emailService.send({ Email email ->
+email.recipient == '[email protected]' &&
+email.subject == 'Test' &&
+email.textBody == 'Hola hola'
+}) // <1>
+}
+
+void 'invalid request without recipient returns 422 with validation
errors'() {
+when:
+RestTemplate client = new RestTemplate()
+HttpClientErrorException ex = null
+try {
+client.postForEntity(
+"http://localhost:$serverPort/mail/send";,
+[
+subject : 'Test',
+textBody: 'Hola hola'
+],
+Map
+)
+} catch (HttpClientErrorException e) {
+ex = e
+}
+
+then:
+ex != null
+ex.statusCode ==
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
sanjana2505006 commented on PR #524: URL: https://github.com/apache/grails-static-website/pull/524#issuecomment-5061281081 @jamesfredley, I addressed the inline notes. Please have another look whenever you get a chance and let me know if there's any other requirements -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
jamesfredley commented on code in PR #524: URL: https://github.com/apache/grails-static-website/pull/524#discussion_r3639505017 ## guides/grails-email/v8/guide/controller.adoc: ## @@ -0,0 +1,24 @@ +Accept JSON payloads with a command object that implements `Email` and validates required fields: + +[source,groovy] +.grails-app/controllers/example/EmailCmd.groovy + +include::../snippets/grails-app/controllers/example/EmailCmd.groovy[] + + +The controller delegates to `EmailService`: + +[source,groovy] +.grails-app/controllers/example/MailController.groovy + +include::../snippets/grails-app/controllers/example/MailController.groovy[] + + +Example request: Review Comment: Please add a prominent safety note before this request example. The tutorial endpoint accepts arbitrary recipients and message content without authentication, so a deployed copy can become an outbound mail relay through the configured provider. State that it is demonstration-only and must have authentication, authorization, recipient controls, and abuse/rate-limit protection before any public or production exposure. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
jamesfredley commented on code in PR #524: URL: https://github.com/apache/grails-static-website/pull/524#discussion_r3639498132 ## guides/grails-email/v8/snippets/grails-app/conf/application.yml: ## @@ -0,0 +1,27 @@ + #tag::mailConfig[] + mail: Review Comment: This vendored fragment omits the required `grails:` parent. In the companion app, `mail:` is nested under `grails:`; copying the rendered snippet as shown creates a root-level block that the Mail plugin will not read. Please include the parent key, ideally by tagging and vending the exact companion-app section. ## guides/grails-email/v8/guide/gettingStarted.adoc: ## @@ -0,0 +1,14 @@ +Clone the repository and verify tests pass: + +[source,bash] + +git clone -b grails8 https://github.com/grails-guides/grails-email.git +cd grails-email/initial +./gradlew test + + +The `initial/` project is a Grails 8 REST API starter with no mail wiring yet. + +To skip ahead, `cd complete` and run the same commands; that tree contains the finished mail services, controller, and integration spec. Review Comment: The preceding commands leave the reader in `grails-email/initial`, so `cd complete` fails because `complete` is a sibling directory. Please use `cd ../complete` here, or show a separate command block that starts from the repository root. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
jamesfredley commented on PR #524: URL: https://github.com/apache/grails-static-website/pull/524#issuecomment-5060308002 Latest-head re-review: the original feedback is addressed, and I resolved those prior threads. `validateGuides -PvalidationMode=both` passes and the targeted guide renders and loads cleanly. A new blocking cross-PR drift remains: the vendored snippets no longer match the companion sample-app head. In particular: - `resources.groovy` still uses `AwsSesMailService` and silently routes unknown providers to SMTP. - `SendGridEmailService.groovy` still drops the HTML alternative and swallows provider failures. - `AwsSesMailService.groovy` retains the old class name and swallows SES failures. - `MailController.groovy` still returns a bare 422. - `MailControllerSpec.groovy` lacks the added invalid-request cases. Please fix the remaining companion-PR blockers first, then re-vendor these files from that corrected head and update the AWS filename/include to `AwsSesEmailService.groovy`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
sanjana2505006 commented on PR #524: URL: https://github.com/apache/grails-static-website/pull/524#issuecomment-5056776749 @jamesfredley I've updated the code please have a look and let me know if there's anything else i can do -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
sanjana2505006 commented on code in PR #524: URL: https://github.com/apache/grails-static-website/pull/524#discussion_r3636917322 ## conf/guides.yml: ## @@ -2190,10 +2190,11 @@ guides: title: Help with Grails - name: 'grails-email' -title: 'Send Email and Spock Spring' -subtitle: 'Learn how to send emails with AWS SES and SendGrid from a Grails app and leverage Spock Spring integration to verify interaction.' +title: 'Sending Email from a Grails 8 Application (and Testing It)' +subtitle: 'Send mail over SMTP or through SendGrid / AWS SES, externalize configuration, and verify send interactions with Spock Spring integration tests — without live email.' authors: - 'Sergio del Amo' + - 'Sanjana' Review Comment: Actually, my legal name is just Sanjana (no surname). I’ve left the author as 'Sanjana.' Let me know if you’d prefer a different convention for mononyms. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Add Grails 8 email guide (v8 prose, snippets, guides.yml) [grails-static-website]
jamesfredley commented on code in PR #524: URL: https://github.com/apache/grails-static-website/pull/524#discussion_r3590437875 ## conf/guides.yml: ## @@ -2190,10 +2190,11 @@ guides: title: Help with Grails - name: 'grails-email' -title: 'Send Email and Spock Spring' -subtitle: 'Learn how to send emails with AWS SES and SendGrid from a Grails app and leverage Spock Spring integration to verify interaction.' +title: 'Sending Email from a Grails 8 Application (and Testing It)' +subtitle: 'Send mail over SMTP or through SendGrid / AWS SES, externalize configuration, and verify send interactions with Spock Spring integration tests — without live email.' Review Comment: Typography: this subtitle uses an em dash (`— without live email`). Project style forbids em/en dashes. Please replace it, for example: `...verify send interactions with Spock Spring integration tests, without live email.` ## conf/guides.yml: ## @@ -2190,10 +2190,11 @@ guides: title: Help with Grails - name: 'grails-email' -title: 'Send Email and Spock Spring' -subtitle: 'Learn how to send emails with AWS SES and SendGrid from a Grails app and leverage Spock Spring integration to verify interaction.' +title: 'Sending Email from a Grails 8 Application (and Testing It)' +subtitle: 'Send mail over SMTP or through SendGrid / AWS SES, externalize configuration, and verify send interactions with Spock Spring integration tests — without live email.' authors: - 'Sergio del Amo' + - 'Sanjana' Review Comment: Please use a full display name here to match convention. The existing author is `Sergio del Amo` (full name), so a bare first name `Sanjana` is inconsistent. Use your full name, e.g. `- 'Sanjana '`. ## conf/guides.yml: ## @@ -2257,6 +2258,45 @@ guides: test: Test helpWithGrails: title: Do you need help with Grails? + '8': +sourcePath: guides/grails-email/v8 +publicationDate: '2026-07-01' +tags: + - 'email' + - 'smtp' + - 'sendgrid' + - 'ses' + - 'aws' + - 'spock-spring' + - 'integration-testing' + - 'mail' +sampleRef: + repo: 'grails-guides/grails-email' + branch: 'grails8' +toc: + introduction: +title: Introduction + requirements: What you will need Review Comment: This TOC entry uses the scalar form while every other entry uses the object form with `title:`. Please make it consistent: ```yaml requirements: title: What you will need ``` ## guides/grails-email/v8/guide/smtpMail.adoc: ## @@ -0,0 +1,17 @@ +The default provider delegates to the Grails Mail plugin: + +[source,groovy] +.grails-app/services/example/SmtpEmailService.groovy + +include::../snippets/grails-app/services/example/SmtpEmailService.groovy[] + + +Configure SMTP settings in `application.yml`: + +[source,yaml] +.grails-app/conf/application.yml + +include::../snippets/grails-app/conf/application-email.yml[] Review Comment: Snippet filename drift. This include points at `application-email.yml`, but the caption on the line above says `.grails-app/conf/application.yml` and the surrounding prose says `application.yml`, while the companion sample-app PR (grails-guides/grails-email#1) names the file `application-development.yml`. These must all agree, otherwise the vendored snippet does not correspond to a real file in the sample repo and will drift or break the AsciiDoc build on snippet sync. Please pick one filename and use it consistently in the sample app, the vendored snippet, the listing caption, and the prose. ## guides/grails-email/v8/guide/gettingStarted.adoc: ## @@ -0,0 +1,17 @@ +Clone the repository and verify tests pass: + +[source,bash] + +git clone -b grails8 https://github.com/grails-guides/grails-email.git +cd grails-email/initial +./gradlew test + + +The `initial/` project is a Grails 8 REST API starter with no mail wiring yet. + +To skip ahead, `cd complete` and run the same commands — that tree contains the finished mail services, controller, and integration spec. + +[[cloneAndRun]] +== Verify CI Review Comment: Chapter titles are supplied by the guide TOC in `guides.yml`. Injecting a `== Verify CI` level-2 heading mid-chapter creates an unexpected or duplicate section level in the rendered guide. Please make this normal prose, or demote it to a `===` subsection if a subsection is intended. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at:
