2013-08-29 29 views
0

我已經在我的pom.xml中添加了這個。我在Windows7上,我正在使用java + testng編寫自動化腳本。 我是否需要postfix smtp服務器來發送電子郵件,這就是爲什麼下面的代碼沒有運行,因爲相同的代碼運行在安裝了postfix的ubuntu機器上。Pom.xml無法發送電子郵件?

<plugin> 
      <groupId>ch.fortysix</groupId> 
      <artifactId>maven-postman-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>send a mail</id> 
        <phase>test</phase> 
        <goals> 
         <goal>send-mail</goal> 
        </goals> 
        <inherited>false</inherited> 
        <configuration> 
         <from>[email protected]</from> 
         <subject> Test Results</subject> 
         <failonerror>true</failonerror> 
         <mailhost></mailhost> 
         <receivers> 
          <receiver>[email protected]</receiver> 

         </receivers> 
         <htmlMessageFile>target/surefire-reports/emailable-report.html</htmlMessageFile> 
</configuration> 
       </execution> 
</plugin> 

回答

2

你需要一些樣的SMTP服務器爲maven-postman-plugin工作。

因此,一種解決方案是在Windows上安裝本地SMTP,但最好將插件配置爲使用公司的郵件服務器。 Look at the various mail* options of the plugin

但也許這不是你想要的。如果你只是想測試發送郵件,那麼在單元測試中運行良好的郵件服務器會更有用(因爲它在發生事故時不會因爲數千封郵件而阻塞真正的郵件服務器)。

一些選項中看到這個問題:Method for email testing

+0

我只是不想測試,但我會發送電子郵件做開發團隊每天的成功/失敗兩個。請給我一個更好的解決方法。我想寫一個適用於Windows和Ubuntu的pom。 – paul

+0

然後配置郵遞員插件以使用您公司的代理服務器。 –