'Identify the sender and subject fields from the `append_to` DocType'

def set_sender_field_and_subject_field(self):

    meta_module = frappe.get_meta_module(self.append_to)
    meta = frappe.get_meta(self.append_to)
    self.subject_field = getattr(meta_module, u'subject_field', u'subject')
    if (not meta.get_field(self.subject_field)):
        self.subject_field = None
    self.sender_field = getattr(meta_module, u'sender_field', u'sender')
    if (not meta.get_field(self.sender_field)):
        self.sender_field = None
