Can't send request password reset email

356 views
Skip to first unread message

Jim S

unread,
Mar 24, 2014, 4:02:09 PM3/24/14
to web...@googlegroups.com
I'm working with a couple of applications where the password reset email isn't sending.  I'm getting this error:

Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 217, in restricted
exec ccode in environment
File "/home/www-data/web2py/applications/ibc2/controllers/default.py", line 92, in <module>
File "/home/www-data/web2py/gluon/globals.py", line 372, in <lambda>
self._caller = lambda f: f()
File "/home/www-data/web2py/applications/ibc2/controllers/default.py", line 54, in user
return dict(form=auth())
File "/home/www-data/web2py/gluon/tools.py", line 1303, in __call__
return getattr(self, args[0])()
File "/home/www-data/web2py/gluon/tools.py", line 2927, in request_reset_password
if self.email_reset_password(user):
File "/home/www-data/web2py/gluon/tools.py", line 2951, in email_reset_password
message=self.messages.reset_password % d):
File "/home/www-data/web2py/gluon/tools.py", line 371, in send
raise Exception('Server address not specified')
Exception: Server address not specified

However, the server name is most definitely set in db.py.

#  configure email
mail = Mail()
mail.settings.server = 'localhost'
mail.settings.sender = 'em...@companyname.com'
mail.settings.login = None
mail.settings.tls = False

I seem to be missing something here, but can't figure out what it might be.  Any pointers from anyone?

-Jim

Niphlod

unread,
Mar 24, 2014, 5:49:31 PM3/24/14
to web...@googlegroups.com
did you try with

mail = auth.settings.mailer
mail.settings.server .....


?

Jim Steil

unread,
Mar 24, 2014, 5:54:43 PM3/24/14
to web...@googlegroups.com
No, I hadn't tried that.  I just did and it fixed it.  Is that the recommended way to setup your mail server now?  I must have done it wrong a long time ago and just kept replicating it.  It works on some of my deployed apps, but not all of them.

-Jim


--
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/mdz4qHx_nPI/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.

Niphlod

unread,
Mar 24, 2014, 6:25:28 PM3/24/14
to web...@googlegroups.com
I just saw how the welcome app is.
The fact is (at least I think, there are a bit of turnarounds in the core code)...

mail = Mail()

is good if you later do

mail.send()

but Auth **needs** a mailer to send messages.

Auth(db) in reality "stands" for

              Auth(   db=None,
                 mailer=True,
                 hmac_key=......
              )

the mailer parameter is treated as follows

mailer=(mailer == True) and Mail() or mailer

So............by default if you don't pass a mailer to Auth(), the default value (True) creates a Mail() object for you.

Current welcome is "smart" in exploiting such shortcuts

auth = Auth(db)
.....
mail
= auth.settings.mailer
mail
.settings.server = 'logging' or 'smtp.gmail.com:587'
mail
.settings.sender = 'y...@gmail.com'
mail
.settings.login = 'username:password'

This "assigns" to the mail variable the Mail() created by Auth (so that Auth can use it), and configures it accordingly

The "other" method would be to

mail=Mail()
mail
.settings.server='smtp.gmail.com:587'
mail
.settings.sender='y...@somewhere.com'
mail
.settings.login='username:password'
auth
=Auth(db)
auth
.settings.mailer=mail
# auth.settings....=...
auth
.define_tables()

In this way, Mail() created by Auth() is "overwritten" by your Mail() with the settings.

Same thing goes with

mail=Mail()
mail
.settings.server='smtp.gmail.com:587'
mail
.settings.sender='y...@somewhere.com'
mail
.settings.login='username:password'
auth
=Auth(db, mailer=mail)

but in this case, Auth doesn't create it, so it's just an assignment and not an override ^__^
Reply all
Reply to author
Forward
0 new messages