Perl programmer for hire: download my resume (PDF).
John Bokma MexIT
freelance Perl programmer

Comments: Using the Mail task in Apache Ant

13 comments

For a big Perl project I am working on for quite some time I decided to use Apache Ant for creating a distribution with all the Perl code and related files. Since Ant has a Mail task, I wanted to see if I could have the files that belonged to a distribution emailed to my customer automatically.

Read the rest of Using the Mail task in Apache Ant.

Comments

hi

i am trying to use this ant mail task in my project but i am always getting error

i had already included mail.jar and activation.jar in my ant library..its very urgent can u help me to figure out the problem

(edit: have replaced the domain names with example.com, JB)

<target name="MAIL">
  <mail mailhost="localhost@example.com" mailport="25" subject="Test build" 
   charset="utf-8">
    <from address="salil_sanghvi@example.com"/>
    <to address="sagar_patel@example.com"/>
    <message>some international </message>
  </mail>
</target>

the error is

Problem while sending mime mail:
Posted by sagar at 07:04 GMT on 14 March 2006

Hi,

This article solved my e-mail-sending Ant task; please keep this item for reference!

Cheers, Peter-Jan Bosch

Posted by Peter-Jan Bosch at 13:31 GMT on 14 March 2006

Thanks for blogging on this! A google search turned up this page, and it quickly solved my can't-handle-MIME problems.

Two additional things to add for other readers:

1.) The mail.jar file that needs to be added to Ant\lib is located in the base directory of the JavaMail download; it is not in the lib directory.

2.) You may also need to set the charset="ISO-8859-1" attribute to the Ant mail task. Thunderbird reads emails fine with or without it but MS Outlook complains about an unsupported (Cp1252) charset that might otherwise be used.

Regards, Glen

Posted by Glen Mazza at 16:33 GMT on 16 March 2006

Thank you for posting this, I was having the same exact problem trying to send an attachment, after adding those two jar files to my classpath i was sending attachments with no errors.

keep up the good work!

Arlen

Posted by Arlen Thurber at 22:26 GMT on 10 May 2006

Hi John,

Thanks for providing informative and elaborative article on sending mail using Ant. I am new to Ant and your article helped me greatly.

One Suggestion: Would be great if you as well let users know that having a Mail Server running on the computer machine where they are running the ANT tool, it would really help them get through it faster.

Thanks very much once again, Bharat

Posted by Bharat at 20:17 GMT on 29 July 2006

This article help me as well. Thanks

Jar files needed are:

mail.jar activation.jar

ANT HOME = e.g. C:\apache-ant-1.6.5 Save them in the {ANT_HOME}\lib directory

Thanks. Cpwere

Posted by Cp.com at 14:50 GMT on 9 October 2006

i also faced the same problem stating MIME problem, but for yr information i already had set mail.jar n activation.jar files into ANT/lib folder path, so instead of having these jar , i was getting error during ANT mail send option.

So i just disable the anti- virus protection over the port 25, n wondered this time it is wrkg fine.

Posted by ranjeet at 09:24 GMT on 21 November 2006

The article helped me to overcome the charset issues that I encountered. Now my problem is solved after I add the charset into

charset="ISO-8859-1"

Thanks, It is a great help

Posted by Dena at 05:45 GMT on 12 January 2007

Hi, I have the two jars described above, I set the charset in my ant, but I still have the same problem. I'm runing ant 1.6.2 on Solaris.

My ant tag is the following:

(edit: have replaced the domain name with example.com, JB)

<target name="send_report">
	<property name="report" value="report.html"/>
	<mail from="JS"
		messagemimetype="text/html"
		charset="ISO-8859-1"
		messagefile="${report}"
		mailhost="<IP>"
		tolist="JS@example.com"
		subject="Build Report"/>
</target>

Thanks in advance.

Posted by RL at 17:13 GMT on 25 April 2007

Thanks for your help. This worked for me too. Best Regards, Mike

Posted by Mike Lutz at 02:27 GMT on 31 December 2007

Thanks, this has been bugging me for months. Worked perfectly. Thank you

Posted by Mark Fleetwood at 09:09 GMT on 4 April 2008

This was the first link from google on the error message and the solution worked for me as well.

Posted by Shep at 22:40 GMT on 26 January 2009

Thanks, after placing mail.jar and activation.jar it is working for me.

-Kiran

Posted by Kiran at 10:39 GMT on 11 January 2012

Post a comment

Note that your comment doesn't show up immediately. I review each comment before I add it to this site.

Check the Follow this page option if you want to receive an email each time a comment is posted to this page, including yours. A link to turn this option off will be included with each email.

Internet adresses will be converted automatically. You can use the following notation to specify anchor text for a link: [url=http://example.com/]example text[/url].