title: Sending email through cron with Django
body: <p>I want to set up a cron job that sends a daily email to all users in my Django project.</p>
  
  <p>I registered the following bash script with cron tab:</p>
  
  <pre><code>#!/bin/bash
  
  PYTHONPATH="${PYTHONPATH}:/path/to/app"
  export PYTHONPATH
  export DJANGO_SETTINGS_MODULE=core.settings.prod
  
  python /path/to/app/cron.py
  </code></pre>
  
  <p>In <code>cron.py</code> the email is sent in: </p>
  
  <pre><code>email = mail.EmailMessage(
      'subject'
      text,
      settings.DEFAULT_FROM_EMAIL,
      [user.email]
  )
  messages.append(email)
  
  connection = mail.get_connection()
  connection.open()
  connection.send_messages(messages)
  connection.close()
  </code></pre>
  
  <p>The cronjob is executed correctly. However, the Postfix logs revealed that wrong email addresses are used as from and to emails. In both cases it's user-who-registered-cronjob@host-regisered-in-postfix. Is there anything, I'm missing here when I set the environment?</p>
  
  <p>Thanks for your help.</p>