title: Python - smtp requires authentication
body: <p>I am trying to send an email using python but despite I am using the local SMTP server it seems that it needs authentication. The code I run and the error I get can be seen below. I use port 587, because port 25 cannot be opened on my server. Could you please help me on setting up the local SMTP server using python on port 587?</p>
  
  <pre><code>&gt;&gt;&gt; import smtplib
  &gt;&gt;&gt; from email.mime.text import MIMEText
  &gt;&gt;&gt; msg = MIMEText('Test body')
  &gt;&gt;&gt; me = 'support@mywebsite.com'
  &gt;&gt;&gt; to = 'myemail@gmail.com'
  &gt;&gt;&gt; msg['Subject'] = 'My Subject'
  &gt;&gt;&gt; msg['From'] = me
  &gt;&gt;&gt; msg['To'] = to
  &gt;&gt;&gt; s = smtplib.SMTP('localhost', 587)
  &gt;&gt;&gt; s.sendmail(me, [to], msg.as_string())
  
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/smtplib.py", line 722, in sendmail
      raise SMTPSenderRefused(code, resp, from_addr)
  smtplib.SMTPSenderRefused: (530, '5.7.0 Authentication required', 'support@mywebsite.com')
  </code></pre>