'Add a header line to the MIME message.
The key is the name of the header, where the value obviously provides
the value of the header. The optional argument prefix determines
where the header is inserted; 0 means append at the end, 1 means
insert at the start. The default is to append.'

def addheader(self, key, value, prefix=0):

    lines = value.split('\n')
    while (lines and (not lines[(-1)])):
        del lines[(-1)]
    while (lines and (not lines[0])):
        del lines[0]
    for i in range(1, len(lines)):
        lines[i] = ('                ' + lines[i].strip())
    value = ('\n'.join(lines) + '\n')
    line = ((key + ':    ') + value)
    if prefix:
        self._headers.insert(0, line)
    else:
        self._headers.append(line)
