'Read emails and publish state change.'

def update(self):

    email_message = self._email_reader.read_next()
    if (email_message is None):
        return
    if self.sender_allowed(email_message):
        message_body = EmailContentSensor.get_msg_text(email_message)
        if (self._value_template is not None):
            message_body = self.render_template(email_message)
        self._message = message_body
        self._state_attributes = {ATTR_FROM: EmailContentSensor.get_msg_sender(email_message), ATTR_SUBJECT: EmailContentSensor.get_msg_subject(email_message), ATTR_DATE: email_message['Date']}
