def set_from_template_string(self, string):
        """
        Reads the given template (SMTP formatted) and sets all fields
        accordingly.

        :type  string: string
        :param string: The template.
        """
        in_header = True
        body = ''
        for line in string.split('\n'):
            if not in_header:
                body += line + '\n'
                continue
            if not _is_header_line(line):
                body += line + '\n'
                in_header = False
                continue
            key, value = _get_var_from_header_line(line)
            if key == 'from':
                self.set_sender(value)
            elif key == 'to':
                self.add_to(value)
            elif key == 'cc':
                self.add_cc(value)
            elif key == 'bcc':
                self.add_bcc(value)
            elif key == 'subject':
                self.set_subject(value)
            else:
                raise Exception('Invalid header field "%s"' % key)
        self.set_body(body.strip())
def set_from_template_string ( self , string ) : in_header = True body = '' for line in string . split ( '\n' ) : if not in_header : body += line + '\n' continue if not _is_header_line ( line ) : body += line + '\n' in_header = False continue key , value = _get_var_from_header_line ( line ) if key == 'from' : self . set_sender ( value ) elif key == 'to' : self . add_to ( value ) elif key == 'cc' : self . add_cc ( value ) elif key == 'bcc' : self . add_bcc ( value ) elif key == 'subject' : self . set_subject ( value ) else : raise Exception ( 'Invalid header field "%s"' % key ) self . set_body ( body . strip ( ) )
Reads the given template (SMTP formatted) and sets all fields
        accordingly.

        :type  string: string
        :param string: The template.