Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client does not have permissions to send as this sender (office 365, grails)

I am continuously receiving following error message while trying to configure grails mail plugin (https://grails.org/plugin/mail) for grails spring security plugin.

Here is my configuration looks so far,


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

    grails.mail.default.from = "[email protected]"

And here is my stack-trace.


    .......| 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

Note: Problem is only find in Grails spring security plugin.

like image 298
Balkrishna Avatar asked Apr 17 '15 06:04

Balkrishna


1 Answers

I ran into the exact same issue. Problem seems to arise due to spring security trying to set "from" attribute in the email as no-reply@localhost. Try adding these lines to the config file

 grails.plugin.springsecurity.ui.register.emailFrom = '[email protected]'
 grails.plugin.springsecurity.ui.forgotPassword.emailFrom = '[email protected]'

note: [email protected] is your office365 email

like image 110
Aasiz Avatar answered Sep 22 '22 12:09

Aasiz