使用Ant发邮件的问题

mvmouse 2004-03-17 01:33:34
Ant的文档中说如果使用需要认证的Smtp发邮件,必须要使用mime来对邮件进行编码,可是我用如下的方式来写脚本
<ant:mail mailhost="smtp.263.net" mailport="25"
messagemimetype="text/html" encoding="MIME"
subject="Test"
user="mouse" password="****" >(后面的from和to省略了)

运行时总是显示
[mail] Failed to initialise MIME mail
[mail] Sending email: Test
[mail] Failed to send email

请高手指点!
...全文
1036 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcheng10 2004-09-02
  • 打赏
  • 举报
回复
问题解决了,多谢楼主,
象下面这样写就可以了,不过ANT要1.61以上。

<?xml version="1.0"?>
<!-- build.xml - a simple Ant buildfile -->
<project name="Simple Buildfile" default="init" basedir=".">
<target name="init">
<mail mailhost="smtp.mailcenter.com.cn" mailport="25" subject="Test sendmail" messagemimetype="text/html" user="xxxx" password="xxxx" >
<from address="xx@xxx.com"/>
<to address="abc@abc.com"/>
<message>I am trying to test send mail by ant </message>
</mail>
</target>
</project>
hcheng10 2004-09-01
  • 打赏
  • 举报
回复
请问楼主,
需要认证的和不需要认证的
build.xml写法有什么不同吗?
hcheng10 2004-09-01
  • 打赏
  • 举报
回复
楼主能把你完整的XML文件贴出来吗?

为什么我的是这个结果呢?
Buildfile: build.xml

init:

BUILD FAILED
file:C:/dist/build.xml:10: The <mail> task doesn't support the "user" attribute.


Total time: 1 second
C:\dist>

-------------------------------------------------------------------------

如果去掉user 和password则是下面的结果。

Buildfile: build.xml

init:
[mail] Sending email: Test sendmail
[mail] Failed to send email

BUILD FAILED
file:C:/dist/build.xml:10: Problem while sending mime mail:

Total time: 12 seconds

----------------------------------------------------------------
下面的是我的build.xml

<?xml version="1.0"?>
<!-- build.xml - a simple Ant buildfile -->
<project name="Simple Buildfile" default="init" basedir=".">


<!-- set global properties for this build -->
<property name="lib" location="../ant15/lib"/>
<property name="classpath" value="${lib}/activation.jar;${lib}/mail.jar"/>
<target name="init">
<mail mailhost="smtp.mailcenter.com.cn" mailport="25" subject="Test sendmail" messagemimetype="text/html" user="xxxx" password="xxxx" >
<from address="xx@xxx.com"/>
<to address="abc@abc.com"/>
<message>I am trying to test send mail by ant </message>
</mail>
</target>
</project>
zcjl 2004-03-18
  • 打赏
  • 举报
回复
没玩过
关注一下
pleonheart 2004-03-18
  • 打赏
  • 举报
回复
关注下
mvmouse 2004-03-18
  • 打赏
  • 举报
回复
解决了,需要两个额外的支持文件加入到Ant的Lib中:mail.jar(http://java.sun.com/products/javamail/)和activation.jar(http://java.sun.com/products/javabeans/glasgow/jaf.html)

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧