send an email using a template - grails

后端 未结 3 793
无人共我
无人共我 2020-12-20 19:40

I want to send an email using a template. I want to have a GSP file where i could style it, and send the email. Currently the send mail function is as follows:



        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 20:14

    well, you can try this code...

    mailService.sendMail {
                to user.email
                from "email@test.com"
                subject "MySubject"
                body(view:'/emails/mailTemplate', model: [a:A])
            }
    

    here mailTemplate.gsp is in view/emails. In body of mail service you can use render syntax. then add '<%@ page contentType="text/html" %>' in top of mailTemplate.gsp

提交回复
热议问题