This page last changed on May 01, 2007 by rosspatterson.

The email publisher can be used to send email to any number of users. It is common to include one user who gets an email for every build and then also send email to every developer who checked code in for this build.

People tend to prefer to use CCTray rather than email for instant notification these days.

Make sure that all of the Merge Publishers, along with the Xml Log Publisher task are done before the <email> publisher, or else you won't be able to include output from the build in the email.
A common mistake is to put the email task in the <tasks> section instead of the <publishers> section. If an error occurs in the <tasks> section, the remaining tasks in that section are skipped, and CC.Net goes right to the <publishers> section. So if you put the <email> tasks in the <tasks> section, you'll never get any failure messages.
The ability to configure notifications for successful builds was added in build 1.3.0.2836. It is available in CCNet 1.3 and later.
<email from="buildmaster@mycompany.com" mailhost="smtp.mycompany.com" mailhostUsername="smtpuser" mailhostPassword="smtppassword" includeDetails="TRUE">
    <users>
        <user name="BuildGuru" group="buildmaster" address="buildguru@mycompany.com"/>
        <user name="JoeDeveloper" group="developers" address="joedeveloper@thoughtworks.com"/>
    </users>
    <groups>
        <group name="developers" notification="change"/>
        <group name="buildmaster" notification="always"/>
    </groups>
</email>

Configuration Elements:

The authentication elements, mailhostUsername and mailhostPassword, are available starting with build 1.1.1.2534. This is an interim release, and the feature has not been included in an official release yet. If you would like to use this functionality, you can download a recent build from http://http://ccnetlive.thoughtworks.com/CCNet%2Dbuilds/
Node Description Type Required Default
mailhost The SMTP server that CruiseControl.NET will connect to to send email. string true n/a
mailhostUsername The user name to provide to the SMTP server. (available in 1.1.1.2534) string false ""
mailhostPassword The password to provide to the SMTP server. (available in 1.1.1.2534) string false ""
from The email address that email will be marked as coming from. string true n/a
includeDetails Whether to send a full report or not. If not, just sends a simple status message with a link to the build report boolean false false
users A set of <user> elements that define who to send emails to. complex true n/a
groups A set of <group> elements that identify which the notification policy for a set of users. complex false n/a

User Configuration Element:

Node Description Type Required
name The user name of a user. For 'real' users, this should match the user name in Source Control. string true
group The group that the user is in. This needs to match the name of one <group> elements. string false
address The (internet form) email address of the user. string true

Users do not need to belong to a group. If they are not in a group then they will only receive emails when they have committed changes that are part of the current build. They will receive an email regardless of whether the build succeeds or fails.

It is essential that the value of the name attribute matches the name for the user in the sourcecontrol system. This is the only way that CCNet can reconcile the user that committed their changes with the address to send the email to.

Group Configuration Element:

Node Description Type Required
name The name of the group, which corresponds to the 'group' values used in the <user> tags. string true
notification Determines when to send email to this group. There are four possible notification values:
  • "always" - send email when any build occurs
  • "change" - send email when the status of the build changes (e.g. from 'success' to 'failed').
  • "failed" - send email when the build fails
  • "success" - send email when the build succeeds
string true

Troubleshooting

You may experience an exception that looks like this when the ccnet server tries to send an email:

System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport failed to connect to the server.

This is likely due to not having CDO properly installed on the build server. To fix this, make sure that you have some sort of email client installed (Outlook Express is probably there by default). Outlook Express doesn't actually initialise CDO until you actually open it, so try and use the client to send an email just to verify that everything works.

You can find further troubleshooting hints on the System.Web.Mail faq site

Document generated by Confluence on Jun 21, 2007 10:33