[admin update 2013-10-28: see the wiki section on email/smtp]
I am totally new at Django and while using its 'send_mail' function, I get this error: [Errno 111] Connection refused I think that's the issue with the firewall.
[admin update 2013-10-28: see the wiki section on email/smtp]
I am totally new at Django and while using its 'send_mail' function, I get this error: [Errno 111] Connection refused I think that's the issue with the firewall.
Our firewall shouldn't block anything like that going out from PythonAnywhere. What do you have in the email server settings (like EMAIL_HOST and EMAIL_USE_TLS) in your settings.py?
settings.py doesn't have anything related to email. The default email host is set as 'localhost'.'EMAIL_USE_TLS' is set as 'false'. I am using: send_mail(data['subject'],data['message'],data['email'], ['myemail@**.com'])
Ah, right. We don't provide an SMTP server right now (it would make it too easy for spammers to use us), so you'll need to specify one in EMAIL_HOST. Do you have access to one that you can use?
Oh.I will use my own. Thank you.
Hi I have the same problem, but I don't have access to an SMTP server -any suggestions appreciated. Preferably free :) I'd only need to send a very low volume
@signalstrength You can use Gmail's SMTP server. I searched for you and found: http://www.jangosmtp.com/Pricing.asp If you can provide convincing reason for mailing(testing?), I could share my SMTP server.
As Aatishnn said the easiest public SMTP server to use would probably be gmail's. You can configure it to accept emails from addresses other than your own. Good instructions are here: http://support.google.com/mail/bin/answer.py?hl=en&answer=22370
@aatishnn ah great thanks I'll try Gmail. jangosmtp.com also looks interesting. I'd just be using it to experiment and for learning purposes, wouldn't ask to share anyone's for such things! Thanks again
@hansel thanks :)
Hi, I'm getting the same exception, I didn't setup or change any mail settings, but I'm making calls to the twitter API.
Hi iahvector,
You'll need to setup your email settings then! If you still get issues then please post the full traceback from your error logs. You need to specify mail settings for Django. It has no way of knowing how you want to send email.
@hansel, I'm not trying to send emails and I probably won't need it to do so soon, do I still need to setup email settings?
Here's the traceback:
Traceback:
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, callback_args, *callback_kwargs)
File "/home/iahvector/twitterWebApp/TwitterWebApp/twitterApp/views.py" in index 26. resp, content = client.request(settings.REQUEST_TOKEN_URL, "GET")
File "/usr/local/lib/python2.7/site-packages/oauth2/init.py" in request 682. connection_type=connection_type)
File "/usr/local/lib/python2.7/site-packages/httplib2/init.py" in request 1597. (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/site-packages/httplib2/init.py" in _request 1345. (response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/local/lib/python2.7/site-packages/httplib2/init.py" in _conn_request 1281. conn.connect()
File "/usr/local/lib/python2.7/site-packages/httplib2/init.py" in connect 1052. raise socket.error, msg
Exception Type: error at / Exception Value: [Errno 111] Connection refused
Ah okay, so you are getting an error when trying to connect to some kind of twitter API? The problem the original poster had was a problem sending email.
Though having visited your web app I'm not sure that it is actually your problem. Check the error logs of your web app and see what's happening there. It's a misconfigured django app. Start by fixing the problem in the error logs and see what comes up then. Your problem isn't related to this one at all.
OK, I'm sorry, I'll start a new post with my problem.
I'm getting the same error ([Errno 111] Connection refused) when trying to send emails using the gmx SMTP server.
import smtplib
server = smtplib.SMTP('mail.gmx.com')
Error:
smtplib.SMTP('mail.gmx.com') File "/usr/lib/python2.7/smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File "/usr/lib/python2.7/smtplib.py", line 311, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python2.7/smtplib.py", line 286, in _get_socket return socket.create_connection((host, port), timeout) File "/usr/lib/python2.7/socket.py", line 571, in create_connection raise err error: [Errno 111] Connection refused
Yup, that's because you have a free account. Free accounts only have HTTP/S access to the outside Internet, and only to a set of whitelisted sites. They also have access to the Gmail mail servers. But they can't access other mail servers, which is why you're getting that error.
So, what account I should have to use non-whitelist API? Is it enough the Hack account?
So, what account I should have to use non-whitelist API? Is it enough the Hack account?
Yes, all paying accounts have unrestricted internet. Let us know if everything works OK?
Yes, it is OK. Thanks, harry.
Thanks for working for poor people. We have more restrictions but thanks anyway. I've being uploading code and trying it for hours now with less bandwith than what you have on any of your phones just to realize that I can't connect to what I need to use cause I have a free account. Well, I guess I'm back to openshift.
We're always happy to add new sites to the whitelist, if they have an official public API?
I'm trying to connect to webmail.nauta.cu and all the mail servers on nauta.cu. Is there any motive you should make a white list? I mean I love this site but it is unconfortable on a free account. All the other hosting services I have found only reduce bandwith o server storage and memory but you have to be connected over ssh wich I can't use. I find the web consoles an all the enviroment really nice. I can do my work, push it to github and then pull it from the console. Almost like Im on my pc, but limitations are killing me and I can't afford even the cheapest of your offers cause I don't even have a credit card. (I would love to pay if I had that money)
Drop us an email? Maybe there's something we can do.
send_mail(email, massage, send_from, send_to, fail_silently=False) Traceback (most recent call last): File "/home/Misha1986/.virtualenvs/env/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 69, in handle self.run_shell(shell=options['interface']) File "/home/Misha1986/.virtualenvs/env/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 61, in run_shell raise ImportError ImportError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/Misha1986/.virtualenvs/env/lib/python3.5/site-packages/django/core/mail/init.py", line 61, in send_mail return mail.send() File "/home/Misha1986/.virtualenvs/env/lib/python3.5/site-packages/django/core/mail/message.py", line 292, in send return self.get_connection(fail_silently).send_messages([self]) File "/home/Misha1986/.virtualenvs/env/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages new_conn_created = self.open() File "/home/Misha1986/.virtualenvs/env/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 58, in open self.connection = connection_class(self.host, self.port, **connection_params) File "/usr/lib/python3.5/smtplib.py", line 251, in init (code, msg) = self.connect(host, port) File "/usr/lib/python3.5/smtplib.py", line 335, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python3.5/smtplib.py", line 306, in _get_socket self.source_address) File "/usr/lib/python3.5/socket.py", line 711, in create_connection raise err File "/usr/lib/python3.5/socket.py", line 702, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused
I cannot send mail.
You have a free account. See http://help.pythonanywhere.com/pages/403ForbiddenError/ and http://help.pythonanywhere.com/pages/SMTPForFreeUsers/
Dang, wish I had seen this 5 days ago. ;-(
Couldn't understand why only gmail was working...
:-( Still, glad you found it eventually!
Hello pythonanywhere! Is there the possiblity to put in the whitelist smtp-relay.sendinblue.com for free account? My problem with smtp.gmail.com is about google block the request from pythonanywhere. Thanks in advance!
It won't matter if it's on the whitelist, since gmail is the only place that you can send SMTP to. If sendinblue have an http interface for mail sending, we can whitelist that. Just send us a link to the API documentation that shows the endpoint for the API.
Hello python anywhere i am having the following error
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/zenusdevelop/Cooperative/project/views/dataentry.py", line 1631, in newmembersapproval
mail.send(msg)
File "/home/zenusdevelop/.local/lib/python3.7/site-packages/flask_mail.py", line 491, in send
with self.connect() as connection:
File "/home/zenusdevelop/.local/lib/python3.7/site-packages/flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "/home/zenusdevelop/.local/lib/python3.7/site-packages/flask_mail.py", line 156, in configure_host
host = smtplib.SMTP_SSL(self.mail.server, self.mail.port)
File "/usr/lib/python3.7/smtplib.py", line 1031, in __init__
source_address)
File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python3.7/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.7/smtplib.py", line 1037, in _get_socket
self.source_address)
File "/usr/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/usr/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
when trying to send an email Am an using a free account and the smtp connection is sendgrid kindly help as i need solution to this
For free accounts we only allow gmail smtp. You would have to upgrade to make smtp connections to other endpoints.
Am having this exception , am using lives plan
Error: Your passwords didn't match.
Password:
Password (again):
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execu
te_from_command_line
utility.execute()
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execu
te
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_
argv
self.execute(*args, **cmd_options)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/contrib/auth/management/commands/createsuperuser
.py", line 79, in execute
return super().execute(*args, **options)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/contrib/auth/management/commands/createsuperuser
.py", line 189, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/home/nelsoneneojo2020/getursales247/accounts/models.py", line 39, in create_superuser
user = self.create_user(email,full_name=full_name,password=password,is_staff=True,is_admin=True,)
self.execute(*args, **cmd_options)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/contrib/auth/management/commands/createsuperuser
.py", line 79, in execute
return super().execute(*args, **options)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/contrib/auth/management/commands/createsuperuser
.py", line 189, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/home/nelsoneneojo2020/getursales247/accounts/models.py", line 39, in create_superuser
user = self.create_user(email,full_name=full_name,password=password,is_staff=True,is_admin=True,)
File "/home/nelsoneneojo2020/getursales247/accounts/models.py", line 31, in create_user
user_obj.save(using=self._db)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 66, in save
super().save(*args, **kwargs)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/db/models/base.py", line 746, in save
force_update=force_update, update_fields=update_fields)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/db/models/base.py", line 795, in save_base
update_fields=update_fields, raw=raw, using=using,
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "/home/nelsoneneojo2020/getursales247/accounts/models.py", line 190, in post_save_user_create_receiver
obj.send_activation()
File "/home/nelsoneneojo2020/getursales247/accounts/models.py", line 173, in send_activation
sent_mail = send_mail(subject,txt_,from_email,recipent_list,html_message=html_,fail_silently=False,)
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/mail/__init__.py", line 60, in send_mail
return mail.send()
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/mail/message.py", line 276, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_m
essages
new_conn_created = self.open()
File "/home/nelsoneneojo2020/.virtualenvs/django2/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open
self.connection = self.connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python3.7/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.7/smtplib.py", line 307, in _get_socket
self.source_address)
File "/usr/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/usr/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
(django2) 11:53 ~/getursales247 $
pls i need help
[edited by admin: formatting]
what was the command that you were trying to run? if you recently upgraded, have you killed and restarted your consoles?