'Sends a boxcar notification to the address provided
msg: The message to send (unicode)
title: The title of the message
email: The email address to send the message to (or to subscribe with)
subscribe: If true then instead of sending a message this function will send a subscription notification (optional, default is False)
returns: True if the message succeeded, False otherwise'

def _sendBoxcar(self, msg, title, email, subscribe=False):

    msg = msg.strip()
    curUrl = API_URL
    if subscribe:
        data = urllib.urlencode({u'email': email})
        curUrl += u'/subscribe'
    else:
        data = urllib.urlencode({u'email': email, u'notification[from_screen_name]': title, u'notification[message]': msg.encode(u'utf-8'), u'notification[from_remote_service_id]': int(time.time())})
    try:
        req = urllib2.Request(curUrl)
        handle = urllib2.urlopen(req, data)
        handle.close()
    except urllib2.HTTPError as e:
        if (not hasattr(e, u'code')):
            sickrage.srCore.srLogger.error(u'Boxcar    notification    failed.    Error    code:    {}'.format(e.message))
            return False
        else:
            sickrage.srCore.srLogger.warning((u'Boxcar    notification    failed.    Error    code:    ' + str(e.code)))
        if (e.code == 404):
            sickrage.srCore.srLogger.warning(u'Username    is    wrong/not    a    boxcar    email.    Boxcar    will    send    an    email    to    it')
            return False
        elif (e.code == 401):
            if subscribe:
                sickrage.srCore.srLogger.error(u'Already    subscribed    to    service')
                return False
            else:
                subscribeNote = self._sendBoxcar(msg, title, email, True)
                if subscribeNote:
                    sickrage.srCore.srLogger.debug(u'Subscription    send')
                    return True
                else:
                    sickrage.srCore.srLogger.error(u'Subscription    could    not    be    send')
                    return False
        elif (e.code == 400):
            sickrage.srCore.srLogger.error(u'Wrong    data    sent    to    boxcar')
            return False
    sickrage.srCore.srLogger.info(u'Boxcar    notification    successful.')
    return True
