diff --git a/master/buildbot/status/mail.py b/master/buildbot/status/mail.py
index 11727bc..66b200c 100644
--- a/master/buildbot/status/mail.py
+++ b/master/buildbot/status/mail.py
@@ -11,19 +11,18 @@ import urllib
 
 from zope.interface import implements
 from twisted.internet import defer, reactor
-from twisted.mail.smtp import ESMTPSenderFactory
+from twisted.mail.smtp import sendmail, ESMTPSenderFactory
 from twisted.python import log as twlog
 
-have_ssl = True
 try:
     from twisted.internet import ssl
     from OpenSSL.SSL import SSLv3_METHOD
 except ImportError:
-    have_ssl = False
+    pass
 
 from buildbot import interfaces, util
 from buildbot.status import base
-from buildbot.status.builder import FAILURE, SUCCESS, Results
+from buildbot.status.builder import FAILURE, SUCCESS, WARNINGS, Results
 
 VALID_EMAIL = re.compile("[a-zA-Z0-9\.\_\%\-\+]+@[a-zA-Z0-9\.\_\%\-]+.[a-zA-Z]{2,6}")
 
@@ -55,6 +54,8 @@ def defaultMessage(mode, name, build, results, master_status):
         text += "The Buildbot has finished a build"
     elif mode == "failing":
         text += "The Buildbot has detected a failed build"
+    elif attrs['mode'] == "warnings":
+        text += "The Buildbot has detected a problem in the build"
     elif mode == "passing":
         text += "The Buildbot has detected a passing build"
     elif mode == "change" and result == 'success':
@@ -149,7 +150,7 @@ class MailNotifier(base.StatusReceiverMultiService):
         @type  fromaddr: string
         @param fromaddr: the email address to be used in the 'From' header.
         @type  sendToInterestedUsers: boolean
-        @param sendToInterestedUsers: if True (the default), send mail to all
+        @param sendToInterestedUsers: if True (the default), send mail to all 
                                       of the Interested Users. If False, only
                                       send mail to the extraRecipients list.
 
@@ -160,9 +161,7 @@ class MailNotifier(base.StatusReceiverMultiService):
                                 developers who made Changes that went into this
                                 build). It is a good idea to create a small
                                 mailing list and deliver to that, then let
-                                subscribers come and go as they please.  The
-                                addresses in this list are used literally (they
-                                are not processed by lookup).
+                                subscribers come and go as they please.
 
         @type  subject: string
         @param subject: a string to be used as the subject line of the message.
@@ -173,6 +172,7 @@ class MailNotifier(base.StatusReceiverMultiService):
         @param mode: one of:
                      - 'all': send mail about all builds, passing and failing
                      - 'failing': only send mail about builds which fail
+                     - 'warnings': send mail if builds contain warnings or fail 
                      - 'passing': only send mail about builds which succeed
                      - 'problem': only send mail about a build which failed
                      when the previous build passed
@@ -205,23 +205,23 @@ class MailNotifier(base.StatusReceiverMultiService):
 
         @type  lookup:    implementor of {IEmailLookup}
         @param lookup:    object which provides IEmailLookup, which is
-                          responsible for mapping User names for Interested
-                          Users (which come from the VC system) into valid
-                          email addresses. If not provided, the notifier will
-                          only be able to send mail to the addresses in the
-                          extraRecipients list. Most of the time you can use a
-                          simple Domain instance. As a shortcut, you can pass
-                          as string: this will be treated as if you had provided
-                          Domain(str). For example, lookup='twistedmatrix.com'
-                          will allow mail to be sent to all developers whose SVN
-                          usernames match their twistedmatrix.com account names.
-
+                          responsible for mapping User names (which come from
+                          the VC system) into valid email addresses. If not
+                          provided, the notifier will only be able to send mail
+                          to the addresses in the extraRecipients list. Most of
+                          the time you can use a simple Domain instance. As a
+                          shortcut, you can pass as string: this will be
+                          treated as if you had provided Domain(str). For
+                          example, lookup='twistedmatrix.com' will allow mail
+                          to be sent to all developers whose SVN usernames
+                          match their twistedmatrix.com account names.
+                          
         @type  customMesg: func
         @param customMesg: (this function is deprecated)
 
         @type  messageFormatter: func
         @param messageFormatter: function taking (mode, name, build, result,
-                                 master_status) and returning a dictionary
+                                 master_status ) and returning a dictionary
                                  containing two required keys "body" and "type",
                                  with a third optional key, "subject". The
                                  "body" key gives a string that contains the
@@ -258,12 +258,11 @@ class MailNotifier(base.StatusReceiverMultiService):
         assert isinstance(extraRecipients, (list, tuple))
         for r in extraRecipients:
             assert isinstance(r, str)
-            # require full email addresses, not User names
-            assert VALID_EMAIL.search(r), "%s is not a valid email" % r 
+            assert VALID_EMAIL.search(r) # require full email addresses, not User names
         self.extraRecipients = extraRecipients
         self.sendToInterestedUsers = sendToInterestedUsers
         self.fromaddr = fromaddr
-        assert mode in ('all', 'failing', 'problem', 'change', 'passing')
+        assert mode in ('all', 'failing', 'problem', 'change', 'passing', 'warnings')
         self.mode = mode
         self.categories = categories
         self.builders = builders
@@ -290,8 +289,8 @@ class MailNotifier(base.StatusReceiverMultiService):
 
         # you should either limit on builders or categories, not both
         if self.builders != None and self.categories != None:
-            twlog.err("Please specify only builders or categories to include not both.")
-            raise interfaces.ParameterError("Please specify only builders or categories to include not both.")
+            twlog.err("Please specify only builders to ignore or categories to include")
+            raise # FIXME: the asserts above do not raise some Exception either
 
         if customMesg:
             twlog.msg("customMesg is deprecated; please use messageFormatter instead")
@@ -337,6 +336,8 @@ class MailNotifier(base.StatusReceiverMultiService):
                builder.category not in self.categories:
             return # ignore this build
 
+        if self.mode == "warnings" and results == SUCCESS:
+            return
         if self.mode == "failing" and results != FAILURE:
             return
         if self.mode == "passing" and results != SUCCESS:
@@ -452,7 +453,7 @@ class MailNotifier(base.StatusReceiverMultiService):
             for k,v in self.extraHeaders.items():
                 k = properties.render(k)
                 if k in m:
-                    twlog.msg("Warning: Got header " + k + " in self.extraHeaders "
+                    twlog("Warning: Got header " + k + " in self.extraHeaders "
                           "but it already exists in the Message - "
                           "not adding it.")
                     continue
@@ -498,8 +499,7 @@ class MailNotifier(base.StatusReceiverMultiService):
         return logname in self.addLogs
 
     def _gotRecipients(self, res, rlist, m):
-        to_recipients = set()
-        cc_recipients = set()
+        recipients = set()
 
         for r in rlist:
             if r is None: # getAddress didn't like this address
@@ -511,44 +511,42 @@ class MailNotifier(base.StatusReceiverMultiService):
                 r = r[:r.rindex('@')]
 
             if VALID_EMAIL.search(r):
-                to_recipients.add(r)
+                recipients.add(r)
             else:
                 twlog.msg("INVALID EMAIL: %r" + r)
 
-        # If we're sending to interested users put the extras in the
-        # CC list so they can tell if they are also interested in the
-        # change:
-        if self.sendToInterestedUsers and to_recipients:
-            cc_recipients.update(self.extraRecipients)
+        # if we're sending to interested users move the extra's to the CC
+        # list so they can tell if they are also interested in the change
+        # unless there are no interested users
+        if self.sendToInterestedUsers and len(recipients):
+            extra_recips = self.extraRecipients[:]
+            extra_recips.sort()
+            m['CC'] = ", ".join(extra_recips)
         else:
-            to_recipients.update(self.extraRecipients)
+            [recipients.add(r) for r in self.extraRecipients[:]]
+
+        rlist = list(recipients)
+        rlist.sort()
+        m['To'] = ", ".join(rlist)
 
-        m['To'] = ", ".join(sorted(to_recipients))
-        if cc_recipients:
-            m['CC'] = ", ".join(sorted(cc_recipients))
+        # The extras weren't part of the TO list so add them now
+        if self.sendToInterestedUsers:
+            for r in self.extraRecipients:
+                recipients.add(r)
 
-        return self.sendMessage(m, list(to_recipients | cc_recipients))
+        return self.sendMessage(m, list(recipients))
+
+    def tls_sendmail(self, s, recipients):
+        client_factory = ssl.ClientContextFactory()
+        client_factory.method = SSLv3_METHOD
 
-    def sendmail(self, s, recipients):
         result = defer.Deferred()
-        
-        if have_ssl and self.useTls:
-            client_factory = ssl.ClientContextFactory()
-            client_factory.method = SSLv3_METHOD
-        else:
-            client_factory = None
 
-        if self.smtpUser and self.smtpPassword:
-            useAuth = True
-        else:
-	    useAuth = False
         
         sender_factory = ESMTPSenderFactory(
             self.smtpUser, self.smtpPassword,
             self.fromaddr, recipients, StringIO(s),
-            result, contextFactory=client_factory,
-            requireTransportSecurity=self.useTls,
-            requireAuthentication=useAuth)
+            result, contextFactory=client_factory)
 
         reactor.connectTCP(self.relayhost, self.smtpPort, sender_factory)
         
@@ -557,5 +555,8 @@ class MailNotifier(base.StatusReceiverMultiService):
     def sendMessage(self, m, recipients):
         s = m.as_string()
         twlog.msg("sending mail (%d bytes) to" % len(s), recipients)
-        return self.sendmail(s, recipients)
-
+        if self.useTls:
+            return self.tls_sendmail(s, recipients)
+        else:
+            return sendmail(self.relayhost, self.fromaddr, recipients, s,
+                            port=self.smtpPort)

