WebFaction
Community site: login faq

Hi,

I trying to send_mail from a django project (both shell and mail) but I have the error:

SMTPServerDisconnected: Connection unexpectedly closed

The settings I use:

  • EMAIL_HOST = 'secure.serverhost.com'
  • EMAIL_HOST_PASSWORD = 'foobarpasswordhere'
  • EMAIL_HOST_USER = 'validemail@example.com'
  • EMAIL_PORT = 465
  • EMAIL_USE_SSL = True

Also, I created a little python script using smtplib but the email was sent normally when ran from my server. So using SSL connections and the credentials I'm using are ok too. Just for the record, my django project also use django-mailer and didn't sent any mails too.

Does anyone have a similar issue after the outgoing settings changed on webfaction?

What am I doing wrong?

asked 24 Feb '16, 03:51

jfunez
16127
accept rate: 100%


ok, I found the solution!!

First, I have to define more settings, now are:

  • EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
  • MAILER_EMAIL_BACKEND = EMAIL_BACKEND
  • EMAIL_HOST = 'secure.serverfoo.com'
  • EMAIL_HOST_PASSWORD = 'passwordbarbaz'
  • EMAIL_HOST_USER = 'myaccount@example.com'
  • EMAIL_PORT = 465
  • EMAIL_USE_SSL = True
  • DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

the settings: MAILER_EMAIL_BACKEND is for django-mailer to work.

the backend: 'django_smtp_ssl.SSLEmailBackend' requires to install: django-smtp-ssl

Also, when testing mailer, I have error when manage.py send_mail tries to retrieve the lock file, just remove the lock file and works good.

permanent link
This answer is marked "community wiki".

answered 25 Feb '16, 03:22

jfunez
16127
accept rate: 100%

wikified 25 Feb '16, 03:22

The recent changes that WebFaction made would only affect connections made to port 25 of external mail servers.

For your problem, please try the following:

  • Change: EMAIL_PORT = 587
  • Remove: EMAIL_USE_SSL = True
  • Add: EMAIL_USE_TLS = True
permanent link

answered 24 Feb '16, 17:04

seanf
12.2k41936
accept rate: 37%

edited 24 Feb '16, 17:06

thanks for you answer @seanf, but doesn't work!

(25 Feb '16, 00:25) jfunez
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×261
×93
×42

question asked: 24 Feb '16, 03:51

question was seen: 10,864 times

last updated: 25 Feb '16, 03:22

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM