5

我試圖運行名爲「playStartApp」的play activator模板。 但是,它給我以下運行時異常:play activator - runtimeException:smtp.host需要在application.conf中設置才能使用此插件(或將smtp.mock設置爲true)

RuntimeException: smtp.host needs to be set in application.conf in order to use this plugin (or set smtp.mock to true)\ 

    java.lang.RuntimeException: smtp.host needs to be set in application.conf in order to use this plugin (or set smtp.mock to true) 
     com.typesafe.plugin.CommonsMailerPlugin$$anonfun$4.apply(MailerPlugin.scala:329) 
     com.typesafe.plugin.CommonsMailerPlugin$$anonfun$4.apply(MailerPlugin.scala:329) 
     scala.Option.getOrElse(Option.scala:120) 
     com.typesafe.plugin.CommonsMailerPlugin.mailerInstance$lzycompute(MailerPlugin.scala:329) 
     com.typesafe.plugin.CommonsMailerPlugin.mailerInstance(MailerPlugin.scala:326) 
     com.typesafe.plugin.CommonsMailerPlugin.onStart(MailerPlugin.scala:343) 
     play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)` 


I tried both: 
- set mail.smtp=mock 

- mail.smtp.host=smtp.gmail.com 
mail.smtp.user=yourGmailLogin 
mail.smtp.pass=yourGmailPassword 
mail.smtp.channel=ssl 

pls suggest how to resolve this? 
+0

我有同樣的問題,你有沒有找到一個解決方案? – Aydin 2014-10-20 14:35:51

回答

3

在「playStartApp」激活模板,您可以 -

  1. 使用一個模擬的郵件,通過輸入以下中的conf /應用.conf文件

    smtp.mock=true 
    

的模擬選項將使電子郵件輸出到控制檯。如果您使用Activator UI,則可以在「運行」選項卡上的日誌中看到郵件輸出。

  • 在CONF提起SMTP服務器的詳細信息/ application.conf

    smtp.host=smtp.gmail.com 
    smtp.port=587 
    smtp.user="[email protected]" 
    smtp.password="password" 
    smtp.ssl=true 
    mail.from="[email protected]" 
    mail.sign=The PlayStartApp Team 
    
  • 可以使用Gmail的服務器來發送郵件,以及,我所提到的以上。

    或者,在「playStartApp」中,只需將conf/mail.conf.example重命名爲conf/mail.conf,並在此處移動所有與SMTP相關的配置。請注意,conf/mail.conf在.gitignore中提及。

    資源(播放文件):

    Mail configuration parameters

    SMTP Configuratoin

    +0

    第一種配置工作正常。謝謝! – Laerte 2015-12-01 16:24:33

    +0

    在測試過程中,如果您使用新的GlobalSettings,您的conf將不會被加載。在這種情況下,將smtp.mock作爲配置傳遞給全局設置:''HashMap configMap = new HashMap <>(); configMap.put(「smtp.mock」,true); application = play.test.Helpers.fakeApplication(configMap,new GlobalSettings());' – saurabheights 2016-12-01 08:10:27

    相關問題