mardi 29 septembre 2015

Mailgun doesnt send mail after hosting django app on aws server

 def send_email_using_mailgun(to_address, reset_link):
     return requests.post(
     "http://ift.tt/1jvuE2m",
     auth=("api", settings.MAILGUN_API_KEY),
     data={"from": "APP_NAME <"+settings.MAILGUN_FROM_ADDRESS+">",
          "to": to_address,
          "subject": "ResetPassword",
          "text": "Click on the link to reset the password" +
           reset_link})


Error: Traceback (most recent call last):
File"/home/ubuntu/django_env/nithenv/local/lib/python2.7/sitepackages/django/core/handlers/base.py", line 112, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/rest_framework/views.py", line 403, in dispatch
response = self.handle_exception(exc)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/rest_framework/views.py", line 400, in dispatch
response = handler(request, *args, **kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
File "/home/ubuntu/django_projects/styleinpocket/StyleInPocket/styleApp/views.py", line 499, in reset_password_api
stat = user.request_reset()
File "/home/ubuntu/django_projects/styleinpocket/StyleInPocket/styleApp/models.py", line 63, in request_reset
return send_email_using_mailgun(self.email_id, reset_link)
File "/home/ubuntu/django_projects/styleinpocket/StyleInPocket/styleApp/helpers.py", line 74, in send_email_using_mailgun
"Follow the link below to set a new password:<a href='" + reset_link + "'>" + reset_link + "</a>"
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/pip/_vendor/requests/api.py", line 109, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/pip/_vendor/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/home/ubuntu/django_env/nithenv/local/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 415, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(110, 'Connection timed out'))

Works fine when testing locally. I receive emails. Doesnt work after pushing code on aws ec2 with nginx and gunicorn. Gives ('Connection aborted.', error(110, 'Connection timed out')). Mailgun Domain authentication is done and shows green ticks on TXT records , CNAME, MX




Aucun commentaire:

Enregistrer un commentaire