title: Django; sending email from my own postfix mail server
body: <p>On the vps where I host a django website, I have set up a postfix mailserver to be used by django for email. The mailserver works. Using mutt on the vps command line, I can send and receive mail to/from other accounts like gmail etc. </p>
  
  <p>Still, I am having trouble using postfix to send mail from django.</p>
  
  <p>I followed the advice in <a href="https://stackoverflow.com/a/28143166/1009979">https://stackoverflow.com/a/28143166/1009979</a>, with settings...</p>
  
  <pre><code>EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  EMAIL_HOST = 'localhost'
  EMAIL_PORT = 25
  EMAIL_HOST_USER = ''
  EMAIL_HOST_PASSWORD = ''
  EMAIL_USE_TLS = False
  </code></pre>
  
  <p>When I try </p>
  
  <pre><code>&gt;&gt;&gt; from django.core.mail import send_mail
  &gt;&gt;&gt; send_mail('Subject here', 'Here is the message.', 'from@example.com', ['andrews.markw@gmail.com'])
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
      return mail.send()
    File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send
      return self.get_connection(fail_silently).send_messages([self])
    File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 107, in send_messages
      sent = self._send(message)
    File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 123, in _send
      self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
    File "/usr/lib/python2.7/smtplib.py", line 733, in sendmail
      raise SMTPRecipientsRefused(senderrs)
  SMTPRecipientsRefused: {u'andrews.markw@gmail.com': (550, '5.7.1 &lt;vps7718.webhosting.uk.com&gt;: Helo command rejected: Host not found')}
  </code></pre>
  
  <p>When I google for advice about <code>SMTPRecipientsRefused:</code> or <code>Helo command rejected: Host not found</code>, no obvious solutions to my problems arise. </p>
  
  <p>Is there something wrong with the settings?</p>
  
  <p>I should mention that I have no general problem problem with django email. For example, I can send gmail emails from django (following settings and procedure described here <a href="https://stackoverflow.com/a/23402208/1009979">https://stackoverflow.com/a/23402208/1009979</a>).</p>