电子邮件地址未在Grails中验证Amazon SES

时间:2015-05-26 16:53:03

标签: grails amazon-ses

我已配置Amazon SES但我无法发送电子邮件。我收到的错误是电子邮件未经过验证,但不可能,因为此电子邮件在我的其他应用中运行正常。

这是错误:

| Error com.amazonaws.services.simpleemail.model.MessageRejectedException: Email address is not verified. (Service: AmazonSimpleEmailService; Status Code: 400; Error Code: MessageRejected; Request ID: 6aab74bb-03c5-11e5-b255-e9ec5d4974cf)
| Error     at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1160)
| Error     at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:748)
| Error     at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:467)
| Error     at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:302)
| Error     at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.invoke(AmazonSimpleEmailServiceClient.java:1443)
| Error     at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.sendEmail(AmazonSimpleEmailServiceClient.java:1170)
| Error     at com.amazonaws.services.simpleemail.AmazonSimpleEmailService$sendEmail$2.call(Unknown Source)
| Error     at org.hscp.email.sender.plugin.SendEmailController.mail(SendEmailController.groovy:44)
| Error     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error     at java.lang.reflect.Method.invoke(Method.java:606)
| Error     at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper.invoke(MixedGrailsControllerHelper.java:154)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleAction(AbstractGrailsControllerHelper.java:375)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.executeAction(AbstractGrailsControllerHelper.java:252)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:205)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:126)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:72)
| Error     at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
| Error     at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:347)
| Error     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
| Error     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
| Error     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
| Error     at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
| Error     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
| Error     at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
| Error     at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
| Error     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
| Error     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
| Error     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
| Error     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
| Error     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
| Error     at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:178)
| Error     at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:144)
| Error     at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:135)
| Error     at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:216)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
| Error     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
| Error     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
| Error     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
| Error     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
| Error     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
| Error     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
| Error     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
| Error     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
| Error     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
| Error     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
| Error     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
| Error     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
| Error     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
| Error     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
| Error     at java.lang.Thread.run(Thread.java:745)
| Error 2015-05-26 17:36:54,191 [http-bio-8080-exec-2] ERROR plugin.SendEmailController  - null

这是我的控制器。

def mail(){
    try{
        log.info "Sending email"
        String source = 'myEmail'
        Destination destination = new Destination(['YourEmail'])
        Content subject = new Content('test')
        Body body = new Body().withHtml(new Content('''Hi,<br />
        <br />
        Some <b>HTML</b> body…
        '''))
        Message message = new Message(subject, body)
        amazonWebService.ses.sendEmail(new SendEmailRequest(source, destination, message))
    }
    catch (Exception e){
        log.error e.printStackTrace()
    }
}

这是我安装的插件:runtime ':aws-sdk:1.9.37.1'

当我添加Amazon SES时,这是我的Config.groovy

environments {
    development {
        grails.logging.jul.usebridge = true
        grails.plugin.awssdk.accessKey = '....'
        grails.plugin.awssdk.secretKey = '....'
    }

    production {
        grails.logging.jul.usebridge = false
        grails.plugin.awssdk.accessKey = '...'
        grails.plugin.awssdk.secretKey = '...'
    }
}

grails.plugin.awssdk.region = 'eu-west-1'

1 个答案:

答案 0 :(得分:0)

您不能简单地调用验证操作,然后立即使用该电子邮件地址,希望对其进行验证。所有验证操作都会导致带有唯一链接的验证电子邮件发送到相关地址,然后收件人必须访问该链接才能完成验证过程,然后才能将该地址用于SES。