code: def _render_mail(self, rebuild, success, auto_canceled, manual_canceled):
          
          subject_template = '%(endstate)s building image %(image_name)s'
          body_template = '\n'.join([
              'Image Name: %(image_name)s',
              'Repositories: %(repositories)s',
              'Status: %(endstate)s',
              'Submitted by: %(user)s',
          ])
  
          # Failed autorebuilds include logs as attachments.
          # Koji integration stores logs in successful Koji Builds.
          # Don't include logs in these cases.
          if self.session and not rebuild:
              body_template += '\nLogs: %(logs)s'
  
          endstate = None
          if auto_canceled or manual_canceled:
              endstate = 'Canceled'
          else:
              endstate = 'Succeeded' if success else 'Failed'
  
          url = self._get_logs_url()
  
          image_name, repos = self._get_image_name_and_repos()
  
          repositories = ''
          for repo in repos:
              repositories += '\n    ' + repo
  
          formatting_dict = {
              'repositories': repositories,
              'image_name': image_name,
              'endstate': endstate,
              'user': '<autorebuild>' if rebuild else self.submitter,
              'logs': url
          }
  
          vcs = self.workflow.source.get_vcs_info()
          if vcs:
              body_template = '\n'.join([
                  body_template,
                  'Source url: %(vcs-url)s',
                  'Source ref: %(vcs-ref)s',
              ])
              formatting_dict['vcs-url'] = vcs.vcs_url
              formatting_dict['vcs-ref'] = vcs.vcs_ref
  
          log_files = None
          if rebuild and endstate == 'Failed':
              log_files = self._fetch_log_files()
  
          return (subject_template % formatting_dict, body_template % formatting_dict, log_files)
docs: Render and return subject and body of the mail to send.