reixa
reixa

Reputation: 7011

Mailing the GSP in Grails with the Mail plugin

I´m sending an email with the Mail Plugin for Grails of a GSP. In this GSP I have added images using ...

src="${resource(dir:'img', file:'line.jpg')}" 

... for example but when I get the email the links seems like they are broken. I think it´s beacause the resources from the Grails project aren´t attached to the mail when this one is created.

Could it be anything else? What can I do to attach the resources files to the email with the plugin or any other way?

Upvotes: 1

Views: 1073

Answers (2)

Victor Sergienko
Victor Sergienko

Reputation: 13475

Looks like Grails' mail plugin has recently added a way to inline images in 1.0 version.

inline() method must work - let me guess how the syntax should look:

mailService.sendMail {
    to m.email
    subject m.emailSubject
    body m.emailBody
    inline 'mylogo', new File(path)
}

where mylogo is resource id that should be referred in m.emailBody like: <img src="mylogo" />

There was a historical way on maillist, but hopefully now you don't need to hack a plugin.

Upvotes: 3

zyro
zyro

Reputation: 515

src="${resource(dir:'img', file:'line.jpg', absolute: 'true')}"

Upvotes: 3

Related Questions