send mail error

80 views
Skip to first unread message

Yebach

unread,
Nov 12, 2014, 3:52:46 AM11/12/14
to web...@googlegroups.com

Hello

I am getting this error on my local Windows machine where I run my web2py server

web2py:Mail.send failure:[Errno 10061] No connection could be made because the target machine actively refused it


Any suggestions?

Thank you

Leonel Câmara

unread,
Nov 12, 2014, 7:30:30 AM11/12/14
to
Well the error is pretty explicit. You configured your mail settings wrong and you're probably connecting to a machine that isn't even running a mailserver.

Vid Ogris

unread,
Nov 12, 2014, 7:38:03 AM11/12/14
to web...@googlegroups.com
Yeah I solved the problem with correcting the settings. 

But another app of my does not even send mail, no error is reported also all setings about registration have no effect

auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True


Any idea why?

2014-11-12 13:30 GMT+01:00 Leonel Câmara <leonel...@gmail.com>:
Well the error is pretty explicit. You configured you mail settings wrong and you're probably connecting to a machine that isn't even running a mailserver.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AxOk3zS8xUE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lep pozdrav 

Vid Ogris


Leonel Câmara

unread,
Nov 12, 2014, 8:43:54 AM11/12/14
to web...@googlegroups.com
That should work:

auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

However, you probably want to add this if you don't want them to login at all until verified

auth.settings.login_after_registration= False

As for why the mail sending is not working and no error messages, I would have to see the mail configuration you're using, you could be using mail.settings.server = 'logging' as far as I know.

Vid Ogris

unread,
Nov 12, 2014, 8:52:00 AM11/12/14
to web...@googlegroups.com
This is my db.py file. It is nothing special. 


# -*- coding: utf-8 -*-
## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request.env.web2py_runtime_gae:
    ## if NOT running on Google App Engine use SQLite or other DB
    db = DAL(settings.database_uri, migrate=settings.migrate)
else:
    ## connect to Google BigTable (optional 'google:datastore://namespace')
    db = DAL('google:datastore')
    ## store sessions and tickets there
    session.connect(request, response, db=db)
    ## or store session in Memcache, Redis, etc.
    ## from gluon.contrib.memdb import MEMDB
    ## from google.appengine.api.memcache import Client
    ## session.connect(request, response, db = MEMDB(Client()))



from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
auth.settings.extra_fields['auth_user'] = [Field('organization', 'reference organization', label = T('Organizacija'))]
## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)


## configure email
mail = auth.settings.mailer
mail.settings.server = 'mx.algit.si:25'
mail.settings.sender = 'alg...@algit.si'
mail.settings.login = 'user.si:pass'
mail.settings.tls = False
## configure auth policy
auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth, filename='private/janrain.key')

Could it be because of my default.py controler

In def user I have

if 'register' in request.args:
form=SQLFORM.factory(db.auth_user.first_name, db.auth_user.last_name, db.auth_user.email, db.auth_user.password, db.organization.o_name)
if form.process().accepted:
id = db.organization.insert(**db.organization._filter_fields(form.vars))
db.auth_user.insert(organization = id, **db.auth_user._filter_fields(form.vars)) #, registration_key = 'pending'
redirect(URL('index'))
return dict(form=form)

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AxOk3zS8xUE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leonel Câmara

unread,
Nov 12, 2014, 9:10:05 AM11/12/14
to web...@googlegroups.com
Yes it is because of your register controller. You're not using the auth provided one which does send the emails.

If you want to change the fields that appear in the default register form you can just use auth.settings.register_fields. You can use auth.settings.register_onvalidation to insert the organization if it doesn't exist and put its id in the vars before onaccept. To let the user put any organization there, you can change its widget to be the text one.

Vid Ogris

unread,
Nov 12, 2014, 9:13:42 AM11/12/14
to web...@googlegroups.com
For organisation field I would like to make it a drop down or insert new one. Your suggestion?

Oh and thank you so very much. I have been struggling with this for a couple of days now

2014-11-12 15:10 GMT+01:00 Leonel Câmara <leonel...@gmail.com>:
Yes it is because of your register controller. You're not using the auth provided one which does send the emails.

If you want to change the fields that appear in the default register form you can just use auth.settings.register_fields. You can use auth.settings.register_onvalidation to insert the organization if it doesn't exist and put its id in the vars before onaccept. To let the user put any organization there, you can change its widget to be the text one.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AxOk3zS8xUE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leonel Câmara

unread,
Nov 12, 2014, 10:58:53 AM11/12/14
to web...@googlegroups.com
I would use the autocomplete widget. If you really want a text input and a combo box I would probably do a custom widget. Here's a full example using the autocomplete widget, this solution uses the welcome app with this added to db.py before auth.define_tables(username=False, signature=False)

db.define_table('organization',
   
Field('name', requires=IS_NOT_EMPTY())
)


auth
.settings.extra_fields['auth_user'] = [
   
Field('organization', 'reference organization', widget=SQLFORM.widgets.autocomplete(request, db.organization.name, id_field=db.organization.id))
]


def add_organization(form):
   
"""
    Adds an organization if it doesn't exist, validates all fields.
    """

   
if not form.vars.organization:
        ret
= db.organization.validate_and_insert(name=form.vars._autocomplete_organization_name_aux)
       
if ret.errors:
            form
.errors.organization = ret.errors['name']
       
else:
            form
.vars.organization = ret.id
   
else:
        output
, error = IS_IN_DB(db, db.organization.id)(form.vars.organization)
       
if error is not None:
            form
.errors.organization = error


auth
.settings.register_onvalidation = add_organization

Vid Ogris

unread,
Nov 13, 2014, 2:28:44 AM11/13/14
to web...@googlegroups.com
Where do I put the def add_ogranization(form) function? In my user.py controler?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AxOk3zS8xUE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leonel Câmara

unread,
Nov 13, 2014, 5:20:04 AM11/13/14
to web...@googlegroups.com
No, all the code in this demo goes into the welcome app (just ask admin to make you a new app), into db.py, before auth.define_tables. All the controllers are the default supplied by welcome.py

 

Vid Ogris

unread,
Nov 13, 2014, 6:17:42 AM11/13/14
to web...@googlegroups.com
Ok.

I inserted your code into db.py 

Now I get an error 

'Table' object has no attribute 'name'


it is in my controler default.py under funcition user()

if 'register' in request.args:
form = auth.register()
return dict(form=form)

Since my app spec changed I don need autocomplete. SO user just inserts (types) the name of organization in filed on register form. 

What do you suggest to be the easyiest way to user auth() form. I think if using SQLFORM.factory sending mail, approvals etc. would be too complicated to do

Thank you for your help

2014-11-13 11:20 GMT+01:00 Leonel Câmara <leonel...@gmail.com>:
No, all the code in this demo goes into the welcome app (just ask admin to make you a new app), into db.py, before auth.define_tables. All the controllers are the default supplied by welcome.py

 

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/AxOk3zS8xUE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vid Ogris

unread,
Nov 13, 2014, 6:30:51 AM11/13/14
to web...@googlegroups.com
Found all my bugs and problems. It was in def add_organization(form):, where I had to change all column names so they match my db. Thanks for the help.




Leonel Câmara

unread,
Nov 13, 2014, 7:49:12 AM11/13/14
to web...@googlegroups.com
Well yes, that was just an example you have to adapt it to your model.

BTW, now you no longer need to have any if 'register' in request.args block in your user function.

No problem, glad to help.
Reply all
Reply to author
Forward
0 new messages