The amazing adventures of Doug Hughes

Ant Can Mail Stuff

On a project we are working on,one thing we needed to do was set up some Ant tasks for deployment to staging and production environments. For the most part, its pretty straightforward, grab latest from SVN repo and then use Ant to replace some text in the main configuration file.

The entire process can take some time, so I looked for some sort of an alert or notification that I could use to signal the job was done. That is when I discovered the <mail> tag in Ant.

That’s right, among all the cool things Ant can do, it can send e-mails, even with attachments if you’d like, and like most things in Ant, once you understand the syntax, its pretty easy.

First, you will need to download 2 .jar files from Sun and place them in the lid directory of your Ant install. These files are mail.jar and activation.jar . (These links will send you to the pages to download entire packages, but all you need are the 2 .jar files in {ANT_HOME}lib) the syntax for the mail tag is pretty straight forward.

<mail mailhost="your mail server" password="password" subject="Subject" user="username">
    <from address="who its from"/>
    <to address="who its to"/>
    <message>Your message goes here</message>
</mail>

If your mail server does not require SMTP authorization, you can leave out the user and password attributes of the mail tag,

For more information on the mail task and it attributes, check out the documentation here.

The more I play around with it, the more I like Ant.

Comments on: "Ant Can Mail Stuff" (4)

  1. Email? I once arrived at a client site, ran their build and a pizza arrived 20 minutes later.

    Like

  2. Jim Priest said:

    Ant rocks! I’ve got a lot of Ant resources here (and will add your post)

    http://www.thecrumb.com/wiki/Ant

    Like

  3. Superb blogging site. Can’t wait to check out just what exactly you think of next!

    Like

  4. could not get on with it myself.

    Like

Comments are closed.

Tag Cloud

%d bloggers like this: