我已经在我的机器上完成了这个 ant 任务(发送电子邮件):
<project name="send_mail_test" default="send_mail_test">
<property name="report" value="${report}" />
<property name="build" value="${build}" />
<property name="env" value="${env}" />
<property name="resultFile" value="${resultFile}" />
<target name="send_mail_test">
<mail encoding="mime" mailhost="mailserver.intranet.lan" subject="[REPORT] ${build} on ${env} environment - Test report" tolist="test@intranet.lan">
<!-- FROM and REPLY TO email addresses -->
<from address="mailman@intranet.lan"/>
<replyto address="noreply@intranet.lan"/>
<message>Some body message
</message>
<attachments>
<fileset dir="${report}" includes="${resultFile}.html"/>
</attachments>
</mail>
</target>
</project>
这就是我开始运行上述脚本的方式(send_mail.xml):
ant -f send_mail.xml -Dreport=C:\TESTING\results -Denv=DEV -Dbuild=1.0.1 -DresultFile=result-2012-07-17-11-03-25.html
它在我的电脑(windows 7)上是成功的,但在另一个 windows xp 上却不是。这是我得到的错误:
Buildfile: C:\TESTING\setup\send_mail.xml
send_mail_test:
[mail] Sending email: [REPORT] C:\TESTING\results on DEV environment - Test report
[mail] Failed to send email: Could not connect to SMTP host: mailserver.intranet.lan, port: 25
BUILD FAILED
C:\TESTING\setup\send_mail.xml:8: Problem while sending mime mail:
Total time: 0 seconds
我意识到我无法连接到邮件服务器,但我该怎么办?无法连接的可能原因是什么?
解决方案:我在这个盒子上安装了 linux。