Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 6391 invoked from network); 13 Dec 2006 19:44:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Dec 2006 19:44:40 -0000 Received: (qmail 65766 invoked by uid 500); 13 Dec 2006 19:44:42 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 65744 invoked by uid 500); 13 Dec 2006 19:44:42 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 63572 invoked by uid 99); 13 Dec 2006 08:16:57 -0000 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=DNS_FROM_RFC_POST,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) From: "heliquan" To: Subject: RE: [ANT] use ant send mail in java code occur erro Date: Wed, 13 Dec 2006 16:14:16 +0800 Message-ID: <007201c71e8e$b17ac1b0$b413a8c0@kdsv> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0073_01C71ED1.BF9E01B0" X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2757 Thread-Index: Accczq+qkIlfhGlATQKkTXX9LiLPGwBv+/tQ X-MAIL: smtp.kingdee.com kBD8EqHf006569 X-Virus-Checked: Checked by ClamAV on apache.org ------=_NextPart_000_0073_01C71ED1.BF9E01B0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit First, Thank you very much! I'm sure the user and password was right. By the error message, I read the ant source code and find execute() method in org.apache.tools.ant.taskdefs.email.EmailTask class was get an instance mailer by org.apache.tools.ant.taskdefs.email.MimeMailer or org.apache.tools.ant.taskdefs.email.UUMailer to send mail, in execute() method it check the mail encoding type first, if the encoding hasn't been set, the instance mailer would be null, then the following send() method will thows some exception. By the source code, i found if i want to use org.apache.tools.ant.taskdefs.email.EmailTask class to send mail, i must call setEncoding(Encoding encoding) method and set the mail encoding firset. Now I call this method and set the mail encoding and use the same user and password, it work ok. Best regard yours, ========================================================================= I would think and authentication error implies the wrong user name and/or password. Have you tried to output the values of both prior sending the email? heliquan wrote: > > Hi, > I use ant in java code to send e-mail,but some error I can't find the > solution. > In java code ,I had new a "org.apache.tools.ant.taskdefs.email.EmailTask" > class object to send email, > but occur an "454 5.7.3 Client was not authenticated."excption. > > The java code like this: > Project pj=new Project(); > pj.init(); > Target tg=new Target(); > tg.setName("mail"); > tg.setProject(pj); > pj.addTarget(tg); > EmailTask mail=new EmailTask(); > mail.setMailhost("192.168.16.2"); > mail.setMailport(25); > mail.setUser("build"); > mail.setPassword("easbuildmail"); > mail.setFrom("build@kdsv.kingdee.com"); > mail.setToList("liujiping@kdsv.kingdee.com"); > mail.setMessage("test mail"); > mail.setSubject("subject"); > mail.setProject(pj); > tg.addTask(mail); > tg.performTasks(); > tg.execute(); > > If i run the code,it would be throw the following exception : > > IO error sending mail > at > org.apache.tools.ant.taskdefs.email.PlainMailer.send(PlainMailer.java:92) > at > org.apache.tools.ant.taskdefs.email.EmailTask.execute(EmailTask.java:556) > at org.apache.tools.ant.Task.perform(Task.java:364) > at org.apache.tools.ant.Target.execute(Target.java:301) > at org.apache.tools.ant.Target.performTasks(Target.java:328) > at com.kingdee.kbs.views.MailTest.main(MailTest.java:46) > Caused by: java.io.IOException: Unexpected reply to command: MAIL FROM: > : 454 5.7.3 Client was not authenticated. > at org.apache.tools.mail.MailMessage.send(MailMessage.java:445) > at org.apache.tools.mail.MailMessage.sendFrom(MailMessage.java:415) > at org.apache.tools.mail.MailMessage.from(MailMessage.java:195) > at > org.apache.tools.ant.taskdefs.email.PlainMailer.send(PlainMailer.java:44) > ... 5 more > --- Nested Exception --- > java.io.IOException: Unexpected reply to command: MAIL FROM: > : 454 5.7.3 Client was not authenticated. > at org.apache.tools.mail.MailMessage.send(MailMessage.java:445) > at org.apache.tools.mail.MailMessage.sendFrom(MailMessage.java:415) > at org.apache.tools.mail.MailMessage.from(MailMessage.java:195) > at > org.apache.tools.ant.taskdefs.email.PlainMailer.send(PlainMailer.java:44) > at > org.apache.tools.ant.taskdefs.email.EmailTask.execute(EmailTask.java:556) > at org.apache.tools.ant.Task.perform(Task.java:364) > at org.apache.tools.ant.Target.execute(Target.java:301) > at org.apache.tools.ant.Target.performTasks(Target.java:328) > at com.kingdee.kbs.views.MailTest.main(MailTest.java:46) > Exception in thread "main" > > The user,password,hostip value ware right which in the java code,use a xml > file with the same value to call ant.bat,it would be ok.My os is windows > 2003, the ant version is 1.6.1 and the jdk version is 1.4.2_11. > What can I doing ? Can you help me? > > > Best regard > yours, > > > ------=_NextPart_000_0073_01C71ED1.BF9E01B0--