Below is the ant tasks showing how to zip reports generated after test run and sending the zip through mail.
//Build.xml
- <target name="sendMail" depends="junitreport,addZip">
- <mail mailhost="smtp.gmail.com" mailport="465" user="my_user_name@gmail.com"
- password="my_password" ssl="on" messagemimetype="text/html"
- charset="ISO-8859-1" subject="Mail subject"
- tolist="myfriend1@gmail.com,myfriend2@gmail.com">
- <from address="my_user_name@gmail.com"/>
- <message>
- Please view index.html page for report in attached zip.
- </message>
- <fileset dir="${zip}"/>
- </mail>
- <echo> Mail is sent successfully </echo>
- </target>
- <target name="addZip">
- <zip destfile="${zip}/testReport.zip" duplicate="preserve">
- <zipfileset dir="${reports.dir}" />
- </zip>
- <zip destfile="${zip}/logs.zip" duplicate="preserve">
- <zipfileset dir="${log.dir}" />
- </zip>
- </target>
Then the 'sendMail' task sends these zip files as email attachment.
In the 'sendMail' target use your own valid credentials for login to mail server. Here i have used
user id: my_user_name@gmail.com
password: my_password
Note: This task is specially for mail sending through gmail. You can change the attribute values for different mail servers as your requirement.