客户端无权作为此发件人发送(Office 365,grails)

时间:2015-04-17 06:29:17

标签: grails spring-security office365 grails-plugin

我在尝试为grails spring安全插件配置grails邮件插件(https://grails.org/plugin/mail)时不断收到以下错误消息。

到目前为止,这是我的配置,


    grails {
        mail {
            host = "smtp.office365.com"
            port = 587
            username = "info@email.com"
            password = "password"
            props = ["mail.smtp.starttls.enable":"true",
                     "mail.smtp.port":"587"]
        }
    }

    grails.mail.default.from = "info@email.com"

这是我的堆栈跟踪。


    .......| Error 2015-04-17 11:59:39,184 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver  - MailSendException occurred when processing request: [POST] /retouch/register/forgotPassword - parameters:
    username: customer
    Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.60 SMTP; Client does not have permissions to send as this sender
    . Stacktrace follows:
    Message: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.60 SMTP; Client does not have permissions to send as this sender
        Line | Method
    ->>  131 | sendMessage    in grails.plugin.mail.MailMessageBuilder
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |     55 | sendMail       in grails.plugin.mail.MailService
    |     59 | sendMail . . . in     ''
    |    156 | forgotPassword in grails.plugin.springsecurity.ui.RegisterController
    |    198 | doFilter . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
    |     63 | doFilter       in grails.plugin.cache.web.filter.AbstractFilter
    |     53 | doFilter . . . in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
    |     49 | doFilter       in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
    |     82 | doFilter . . . in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
    |   1145 | runWorker      in java.util.concurrent.ThreadPoolExecutor
    |    615 | run . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    745 | run            in java.lang.Thread

注意:问题只能在Grails spring安全插件中找到。

3 个答案:

答案 0 :(得分:6)

我遇到了完全相同的问题。问题似乎是由于春季安全试图设置"来自"电子邮件中的属性为no-reply @ localhost。 尝试将这些行添加到配置文件

 grails.plugin.springsecurity.ui.register.emailFrom = 'info@email.com'
 grails.plugin.springsecurity.ui.forgotPassword.emailFrom = 'info@email.com'

注意:info@email.com是您的office365电子邮件

答案 1 :(得分:4)

用户名=" info@emal.com "

grails.mail.default.from =" info@email.com "

用户名电子邮件必须等于电子邮件。

答案 2 :(得分:3)

我使用测试GMail帐户很容易发送Grails发送电子邮件,但是当我尝试从outlook.office365.com帐户发送时,代码因错误而崩溃:

  

邮件失败:com.sun.mail.smtp.SMTPSendFailedException:550 5.7.60   SMTP;客户端无权作为此发件人发送

事实证明我只是错过了这一行:

fromRational

请注意,class Base(object): def a(self, b): print "a",b class Shadow(Base): def a(self, b): if b is None: print 'local',b else: super(Shadow,self).a(b) c = Shadow() c.a(5) c.a(None) c.a(6) 中指定的电子邮件地址必须与grails.mail.default.from = "sample@somewhere.com" 中的电子邮件地址相匹配。

这是适合我的配置。基本示例是Grails in Action(第2版)中的Hubbub示例:

grails.mail.default.from

以下是相应的电子邮件发送功能:

grails.mail.username