开发者

Failed to initialise MIME mail: javax/mail/MessagingException while running Ant Script

I am trying to send email from Ant Script. here is the code snippet

开发者_StackOverflow
<mail mailhost="smtp.gmail.com" subject="Test Email" user="gmailUser" password="gmailPassword">
        <from address="xxxxx@gmail.com" />
        <to address="xxxxx@gmail.com" />
        <message>Test</message>
    </mail>

When I run this script, I am getting an exception

 [mail] Failed to initialise MIME mail: javax/mail/MessagingException

Any Ideas?

Note - Ant version in eclipse is 1.7 and I have added following jars to the build path

mail.jar
dsn.jar
imap.jar
mailapi.jar
pop3.jar
smtp.jar


I was able to get this to work by putting the jar files in ant/lib and setting the MIME type as follows:

<mail mailhost="${email.host}" mailport="${email.port}" subject="${email.subject}"
      from="${email.from}" tolist="${email.to}"
      encoding="mime" messagemimetype="text/html" >
   <message>Your message here</message> 
</mail> 


You also need the Java Activation Framework (usually shipped in activation.jar).


Try and it work for me after downloading javamail-1_3_3_01.zip and jaf-1.0.2.zip. It has all jar files we need for ant 1.7.X (mail.jar, dsn.jar, imap.jar, mailapi.jar, pop3.jar,smtp.jar)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜