最佳答案
我似乎错过了 documentation 中的附件部分。我看到的是 TODO 部分(顺便说一句,应该更新)。不管怎样,这里有一个比那里提到的更清晰的例子。
String path = "./web-app/images/grails_logo.jpg"
sendMail {
multipart true
to '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b5a575d495e5f7b5d595648545d4f4c5a495e15585456" rel="noreferrer noopener nofollow">[email protected]</a>'
subject "Welcome to Grails!"
body '''
Greetings Earthlings!
'''
attachBytes path,'image/jpg', new File(path).readBytes()
}
有了这个,您可以附加任何类型的文件,只要您正确指定我猜的内容类型。
关于grails - 使用 Mail 插件在 Grails 中附加文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2295192/