2015-04-17 45 views
6

Tôi liên tục nhận được thông báo lỗi sau khi cố định cấu hình plugin thư grails (https://grails.org/plugin/mail) cho plugin bảo mật mùa xuân grails.Khách hàng không có quyền gửi với tư cách người gửi này (office 365, grails)

Dưới đây là cấu hình của tôi trông cho đến nay,

 

    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]" 

Và đây là của tôi 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 

Lưu ý: Sự cố chỉ tìm thấy trong plugin bảo mật mùa xuân Grails.

Trả lời

6

Tôi đã gặp sự cố tương tự. Vấn đề dường như phát sinh do an ninh mùa xuân cố gắng đặt thuộc tính "từ" trong email là không trả lời @ localhost. Hãy thử thêm những dòng này vào tập tin cấu hình

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

lưu ý: [email protected] là bạn email Office365

+0

Giải pháp này phù hợp với tôi. Cảm ơn bạn. – Balkrishna

+1

bạn cũng nên thêm grails.plugin.springsecurity.ui.forgotPassword.emailFrom = '[email protected]' dòng – Aasiz

+0

Tôi không cần 2 dòng "chu kỳ an toàn" trở lại. Tôi chỉ thiếu phần "grails.mail.default.from" để truy cập office365.com. (Lưu ý điều này là không cần thiết khi sử dụng tài khoản người gửi Gmail) –

3

username = "[email protected]"

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

tên người dùng email phải bằng từ email.

+0

Xin lỗi đây không phải là trường hợp. Tôi biết cả hai email đều giống nhau. Đây chỉ là lỗi đánh máy trong khi thay đổi email gốc. – Balkrishna

3

tôi đã Grails gửi email khá dễ dàng sử dụng một tài khoản thử nghiệm GMail, nhưng mã rơi với lỗi khi tôi cố gắng gửi từ tài khoản outlook.office365.com:

Thông báo lỗi: com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.60 SMTP; Khách hàng không có quyền để gửi như gửi này

Hóa ra tôi chỉ thiếu dòng này:

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

Lưu ý các địa chỉ email được chỉ định trong grails.mail.default.from phải phù hợp với một trong grails.mail.username.

Đây là cấu hình hoạt động cho tôi. Ví dụ cơ bản là ví dụ huyên náo từ Grails cuốn sách trong Action (2nd Ed):

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

và đây là email tương ứng gửi chức năng:

def email() { 
    println("Sending email.."); 
    sendMail { 
     to "[email protected]" 
     subject "[mail-test]" 
     body ("This is a test email, time: " + new Date()) 
    } 
    println(" success!!!"); 
    flash.message = "Successfully sent email" 
    redirect(uri: "/"); 
} 
Các vấn đề liên quan