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 ^__^

On Monday, March 24, 2014 10:54:43 PM UTC+1, Jim S wrote:
>
> 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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to