Hello, people! I'm migrating an app from Grails 3...
# questions
j
Hello, people! I'm migrating an app from Grails 3.2.3 (web-app) to Grails 6.2.3 (rest-api). Recently i found an issue with the Mail plugin. I was using mail:2.0.0.RC6 and now i'm using mail:4.0.0 When i call
Copy code
mailService.sendMail {
				to "<mailto:your@name.com|your@name.com>"
				from "fromEmail"
				subject "titleMail"
				html view: "/email/auth/verificationCode", model: [:]
}
i get the following error:
Copy code
Could not locate mail body /email/auth/verificationCode. Is it in a plugin? If so you must pass the plugin name in the [plugin] variable.
The view file is located at:
grails-app/views/email/auth/verificationCode.gsp
The error is thrown when I run the project with the generated war. I found that the plugin searchs for the file under "`/WEB-INF/grails-app/views/email/auth/verificationCode.gsp`" BUT the generated war saves the file under "`WEB-INF/classes/email/auth/verificationCode.gsp`" So I was wondering why the war structure changed from
/WEB-INF/grails-app/views
to
WEB-INF/classes/
. Is it related to the change of project type (now rest-api and before web-app)? If so, what other changes should I be aware of regarding this new project type? And finally, but most important, how can I solve this issue to be able to use the Mail plugin? Thank you all! Slack Conversation
t
Hi @José Ignacio Seluy, I haven't worked with a Grails 6 rest-api project before, but in my Grails 6 web-app project I was able to have the mail plugin send emails in a similar fashion to your source code. It worked when running with
./gradlew bootRun
and when running the
myapp-6.0.7-plain.war
file on Tomcat that was generated via
./gradlew assemble
. The only difference that stands out to me is your view file is nested one directory level deeper than mine; my file is located at
grails-app/views/correspondence/mobileVerificationCodeEmail.gsp
. I would try moving your file to
grails-app/views/email/verificationCode.gsp
(and obviously change your mailService call so it includes
html view: "/email/verificationCode", model: [:]
) and see if that resolves the problem. I seem to remember having troubles before with JSON views (
.gson
) that were in a nested directory structure...