title: Send an email from a Python3 script with localhost?
body: <p>I need to send mails from my Python3 script. Now it does, but my gmail password is visible and I cannot trust in any admin of this machine, so the solution I see is to mount a local mail server. To do some tests, I was trying to execute a script (this one: <a href="https://djangosnippets.org/snippets/96/" rel="nofollow noreferrer">SMTP sink server</a>). While this one is running, I execute my old script with some changes:</p>
  
  <pre><code>import smtplib
  
  # server = smtplib.SMTP('smtp.gmail.com:587')
  server = smtplib.SMTP('localhost:25')
  # smtp.ehlo()
  # server.starttls()
  # smtp.ehlo()
  # server.login('my_account@gmail.com', 'my_password')
  server.login(None, None)
  server.sendmail('Me &lt;my_account@gmail.com'&gt;, ['to_user@gmail.com'], 'Hi!'.as_string())
  server.quit()
  </code></pre>
  
  <p>I understand the script at the link will create a file in the folder where it is with the mail content, but nothing happens, because I get this error message:</p>
  
  <pre><code>SMTP AUTH extension not supported by server.
  </code></pre>
  
  <p>I googled and I think this could be sorted out if I uncomment the line <code>server.starttls()</code>, but it gives another error, which is supposed to be solved with the lines <code>smtp.ehlo()</code>, but not in my case.</p>
  
  <p>Any suggestions?</p>