2014-11-14 105 views
0

我在嘗試通過Gmail發送電子郵件時遇到此錯誤。以下是config.groovy文件中的代碼。未通過Gmail發送電子郵件 - 未接受用戶名和密碼

mail.MailMessageBuilder Failed to send email 
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 
535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 ca4sm3178528pbd.79 - gsmtp 

     at grails.plugin.mail.MailMessageBuilder$_sendMessage_closure1.doCall(MailMessageBuilder.groovy:112) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
     at java.lang.Thread.run(Thread.java:745) 
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 
535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 ca4sm3178528pbd.79 - gsmtp 

     at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:843) 
     at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:765) 
     at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:687) 
     at javax.mail.Service.connect(Service.java:345) 
     ... 4 more 

CODE:

grails { 
    mail { 
     host = "smtp.gmail.com" 
     port = 465 
     username = "[email protected]" 
     password = "TTYUIoiuy78" 
     props = ["mail.smtp.auth":"true", 
       "mail.smtp.socketFactory.port":"465", 
       "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory", 
       "mail.smtp.socketFactory.fallback":"false"] 
    } 
} 

我試圖從提供的鏈接建議的解決方案。

我登錄並更改了我的密碼。 我打開驗證碼DisplayUnlockCaptcha 我也點擊了allow less secure apps access the app

+0

試試這個HTTP您的應用程序: //www.rocketideas.com/2012/05/gmail-error-password-not-accepted-from-server-solved/ – user1690588 2014-11-14 17:14:24

回答

0

我遵循這些步驟,我沒有得到任何錯誤,做工精細..

  1. 使用命令

    安裝Grails的郵件插件
    grails install-plugin mail 1.0.7 
    
  2. Config.groovy的開放和追加這些線路

    grails { 
         mail { 
           host = "smtp.gmail.com" 
           port = 465 
           username = "your gmail id" 
           password = "your password" 
           props = ["mail.smtp.auth":"true", 
           "mail.smtp.socketFactory.port":"465", 
           "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory", 
           "mail.smtp.socketFactory.fallback":"false"] 
           } 
         } 
    
  3. 在操作,你要發送的郵件使用此代碼

    sendMail { 
         to "recepient address" 
         subject "Hello Fred" 
         body 'How are you?' 
         } 
    
  4. 編譯使用

    grails compile 
    
  5. 運行的應用程序

+0

礦也窩rks在本地,但不在遠程服務器上。 – Illep 2014-11-15 13:08:46

相關問題