1

I am having an issue with send_mail in Django. It has been working fine until I tried to change some Email settings to have it use an EMAIL_HOST_USER and EMAIL_HOST_PASSWORD. When I did that my test emails where not sent.

I reverted back to my old email settings that did work and now it is still not sending emails. I have restarted things to make sure that my current settings are in effect. When I run the commmand 'python manage.py send_mail' to test I get this response:

acquiring lock... lock already in place. quitting.

In looking at the code in mailer.engine:

def send_all():
    """
    Send all eligible messages in the queue.
    """

    lock = FileLock("send_mail")

    logging.debug("acquiring lock...")
    try:
        lock.acquire(LOCK_WAIT_TIMEOUT)
    except AlreadyLocked:
        logging.debug("lock already in place. quitting.")
        return
    except LockTimeout:
        logging.debug("waiting for the lock timed out. quitting.")
        return
    logging.debug("acquired.")

    start_time = time.time()

    dont_send = 0
    deferred = 0
    sent = 0

It appears that because it gets the exception 'AlreadyLocked' it exits without sending the emails. If this is truly the case, how do I break this lock and start over?

johnnyRose
  • 7,310
  • 17
  • 40
  • 61
Cyrus Cold
  • 269
  • 2
  • 11

1 Answers1

7

most probably there is a "lock file" ('send_mail') in your directory - just remove it

Jerzyk
  • 3,662
  • 23
  • 40
  • note: if this was run through crontab. the send_mail file was in the home directory of the user – abarax May 02 '18 at 00:25