'Email sent from an MTA via SMTP+TLS has TLS headers'

def test_smtp_headers(self):

    import smtplib
    import imaplib
    (msg, subject) = new_message('someone@example.com', TEST_ADDRESS)
    s = smtplib.SMTP(TEST_SERVER, 25)
    s.starttls()
    s.sendmail('someone@example.com', [TEST_ADDRESS], msg)
    s.quit()
    sleep(1)
    m = imaplib.IMAP4_SSL(TEST_SERVER, 993)
    m.login(TEST_ADDRESS, TEST_PASSWORD)
    m.select()
    (_, res) = m.search(None, '(SUBJECT    "{}")'.format(subject))
    (_, data) = m.fetch(res[0], '(RFC822)')
    self.assertIn('ECDHE-RSA-AES256-GCM-SHA384    (256/256    bits)', data[0][1])
    m.store(res[0].strip(), '+FLAGS', '\\Deleted')
    m.expunge()
    m.close()
    m.logout()
