Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect via SMTP #58

Closed
LukasReschke opened this issue Jun 26, 2016 · 5 comments
Closed

Can't connect via SMTP #58

LukasReschke opened this issue Jun 26, 2016 · 5 comments

Comments

@LukasReschke
Copy link
Member

I just tried to deploy this here and everything works fine, except the SMTP part which makes registering impossible. As soon as somebody tries to register a verification mail will be sent but somehow Django refuses to connect properly to the SMTP.

I've configured the following and on the virtual machine next to this one the settings work quite fine for phpList:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mx.nextcloud.com'
EMAIL_HOST_PASSWORD = 'VALID_PASSWORD'
EMAIL_HOST_USER = 'VALID_USER'
EMAIL_USE_TLS = True
EMAIL_PORT = 587

The thrown error is:

Environment:


Request Method: GET
Request URL: http://apps.weasel.rocks/github/login/callback/?code=56de6e976a6f07e4d69f&state=ybGbtidE7F9B

Django Version: 1.9.7
Python Version: 3.5.1
Installed Applications:
['nextcloudappstore.core.apps.CoreConfig',
 'parler',
 'captcha',
 'rest_framework',
 'corsheaders',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.github',
 'allauth.socialaccount.providers.bitbucket',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.sites',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/opt/appstore/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/opt/appstore/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/appstore/lib/python3.5/site-packages/allauth/socialaccount/providers/oauth2/views.py" in view
  62.                 return self.dispatch(request, *args, **kwargs)

File "/opt/appstore/lib/python3.5/site-packages/allauth/socialaccount/providers/oauth2/views.py" in dispatch
  135.             return complete_social_login(request, login)

File "/opt/appstore/lib/python3.5/site-packages/allauth/socialaccount/helpers.py" in complete_social_login
  145.         return _complete_social_login(request, sociallogin)

File "/opt/appstore/lib/python3.5/site-packages/allauth/socialaccount/helpers.py" in _complete_social_login
  158.         ret = _login_social_account(request, sociallogin)

File "/opt/appstore/lib/python3.5/site-packages/allauth/socialaccount/helpers.py" in _login_social_account
  59.                          signal_kwargs={"sociallogin": sociallogin})

File "/opt/appstore/lib/python3.5/site-packages/allauth/account/utils.py" in perform_login
  145.             send_email_confirmation(request, user, signup=signup)

File "/opt/appstore/lib/python3.5/site-packages/allauth/account/utils.py" in send_email_confirmation
  311.                                                     signup=signup)

File "/opt/appstore/lib/python3.5/site-packages/allauth/account/models.py" in send_confirmation
  58.         confirmation.send(request, signup=signup)

File "/opt/appstore/lib/python3.5/site-packages/allauth/account/models.py" in send
  122.         get_adapter(request).send_confirmation_mail(request, self, signup)

File "/opt/appstore/lib/python3.5/site-packages/allauth/account/adapter.py" in send_confirmation_mail
  396.                        ctx)

File "/opt/appstore/lib/python3.5/site-packages/allauth/account/adapter.py" in send_mail
  128.         msg.send()

File "/opt/appstore/lib/python3.5/site-packages/django/core/mail/message.py" in send
  292.         return self.get_connection(fail_silently).send_messages([self])

File "/opt/appstore/lib/python3.5/site-packages/django/core/mail/backends/smtp.py" in send_messages
  100.             new_conn_created = self.open()

File "/opt/appstore/lib/python3.5/site-packages/django/core/mail/backends/smtp.py" in open
  58.             self.connection = connection_class(self.host, self.port, **connection_params)

File "/usr/lib/python3.5/smtplib.py" in __init__
  251.             (code, msg) = self.connect(host, port)

File "/usr/lib/python3.5/smtplib.py" in connect
  335.         self.sock = self._get_socket(host, port, self.timeout)

File "/usr/lib/python3.5/smtplib.py" in _get_socket
  306.                                         self.source_address)

File "/usr/lib/python3.5/socket.py" in create_connection
  711.         raise err

File "/usr/lib/python3.5/socket.py" in create_connection
  702.             sock.connect(sa)

Exception Type: ConnectionRefusedError at /github/login/callback/
Exception Value: [Errno 111] Connection refused

cc @adsworth @BernhardPosselt Any ideas?

@adsworth
Copy link
Contributor

are you sure that it's pulling those settings? It looks like it's trying to connect somewhere that isn't accepting connnections and:

[21:59 adi ~]$ telnet mx.nextcloud.com 587
Trying 88.198.160.131...
Connected to mx.nextcloud.com.
Escape character is '^]'.
220 nextcloud.com ESMTP Postfix (Debian/GNU)
QUIT
221 2.0.0 Bye
Connection closed by foreign host.

that works. So I think it's trying to connect somewhere else.

@LukasReschke
Copy link
Member Author

Interesting! I now looked at the stack trace a little bit more and it shows something contradicting:

2016-06-26_22-04-40

Just wondering why it eats the port but not the domain name … mhm … 

Sorry. I am an absolute Python newbie 😉

@LukasReschke
Copy link
Member Author

Ok. I'm officially stupid, when I entered the SMTP config I didn't notice that at the end of the default file another mail host was already defined.

Working now 🙈

@adsworth
Copy link
Contributor

that has tod o with the time of day and day of week, not intelligence. :)

@BernhardPosselt
Copy link
Member

Btw, got apache working using

<VirtualHost *:80>
WSGIDaemonProcess apps python-home=/opt/appstore/venv python-path=/opt/appstore
WSGIProcessGroup apps
WSGIScriptAlias / /opt/appstore/nextcloudappstore/wsgi.py


Alias /static/ /var/www/html/static/
Alias /schema/apps/info.xsd /opt/appstore/nextcloudappstore/core/api/v1/release/info.xsd

<Directory /opt/appstore/nextcloudappstore>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

<Directory /opt/appstore/nextcloudappstore/core/api/v1/release>
    <Files info.xsd>
        Require all granted
    </Files>
</Directory>

<Directory /var/www/html/static>
    Require all granted
    AllowOverride None
</Directory>

<Directory /var/www/html/media>
    Require all granted
    AllowOverride None
</Directory>
</VirtualHost>

All changes in python code now need to be reloaded by restarting (or maybe reloading) apache :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants