Grails 世界的新手。我在将逗号分隔的表单值从表单传递到 grails 邮件插件的“TO”属性时遇到问题。无论我尝试什么,我似乎都可以将它放入一个数组或接受多个电子邮件地址。
我收到以下错误;我已经删除了域名,所以请忽略它们。
Could not parse mail; nested exception is javax.mail.internet.AddressException:
Illegal address in string ``"ian@email.com","ian@otheremail.com"''
现在挠头,任何关于我在下面的代码中哪里出错的想法。我完全被难住了。!!
在 emailpublication GSP 表格中我有。这些字段是从数据库和文档 ID 中自动填充的。
<g:form action="emailpublication">
<g:field type="text" name="whogetsemail" value="${publicationInstance?.portfolio?.emailtemplates?.toemailtemplate}" />
<g:field type="text" name="publicationName" value="${publicationInstance?.publicationName}" />
<g:textArea type="text" name="publicationContent" value="${publicationInstance?.publicationContent}" cols="20" rows="20"/>
<g:hiddenField name="id" value="${publicationInstance?.id}" />
<input type="submit" value="Send Email"/>
</g:form>
在发布控制器中,我有以下内容;我需要通过 emailpublication gsp 表单中 whogetsemail 字段填充的一个或多个电子邮件地址发送至
def emailpublication(){
List<String> recipients = request.getParameterValues("whogetsemail")
try {
sendMail{
to (recipients.toArray())
from "ineilsen@emailaddress.com"
subject params.publicationName
text params.emailbodyheader + "\n"+"\n" + params.publicationContent + "\n"+"\n" + params.footeremailtemplate
}
}
catch (MailException e) {
log.error "Failed to send emails: $e.message", e
}
catch (MessagingException e) {
log.error "Failed to send emails: $e.message", e
}
redirect(uri: "/publication/show/${params}")
flash.message = "${params.publicationName} sent to ${params.emailto}"
}
谢谢大家,期待回复,我很沮丧