[web2py] Re: how to access auth_user.email to send an email

2012-09-19 Thread greaneym
Thank you, Anthony I will try this and re-read ch 3.


On Tuesday, September 18, 2012 7:51:09 PM UTC-5, greaneym wrote:
>
> Hello,
>
> In testing the registration on my app, I am confused about how to send a 
> new
> user an email.
>
> When a new user is registering using the defaults that come with web2py,
> I can see in the db that for a new user, there is a field 
> db.auth_user.email,
> so I am trying to use that to send a mail to the new user, and using
> the "logging" mechanism to test.
>
> in the model db.py I try adding this:
>
> newuser = db(db.auth_user.email==email).select()
> mail.send(to=['newuser'],
>   subject='Welcome, etc.',
>   # If reply_to is omitted, then mail.settings.sender is used
>   reply_to='myemailaddr...@gmail.com',
>   message='You will be able to login when you receive another 
> email stat
> ing that the registration is completed.'),
>
>
> Also tried
> mail.send(to'['db.auth_user.email'],
>
> in both cases the To: field gets populated with exactly those fields,
>
> To: newuser  or To: db.auth_user.email
>
> How do I access this variable please?
>
> I don't see an example in the book or the cookbook, or in the web2py-users 
> group
> that explains in a way I understand.
>
> thanks for any help,
> Margaret
>
>

-- 





[web2py] Re: how to access auth_user.email to send an email

2012-09-18 Thread Anthony
In mail.send(), the "to" argument has to be a list of actual email 
addresses. You are giving it a string that is the name of a variable that 
holds a DAL Rows object (but it treats the string itself as the email 
address). You want something more like:

newuser = db(db.auth_user.email==email).select().first()
mail.send(to=[newuser.email], ...)

Anthony

On Tuesday, September 18, 2012 8:51:09 PM UTC-4, greaneym wrote:
>
> Hello,
>
> In testing the registration on my app, I am confused about how to send a 
> new
> user an email.
>
> When a new user is registering using the defaults that come with web2py,
> I can see in the db that for a new user, there is a field 
> db.auth_user.email,
> so I am trying to use that to send a mail to the new user, and using
> the "logging" mechanism to test.
>
> in the model db.py I try adding this:
>
> newuser = db(db.auth_user.email==email).select()
> mail.send(to=['newuser'],
>   subject='Welcome, etc.',
>   # If reply_to is omitted, then mail.settings.sender is used
>   reply_to='myemail...@gmail.com ',
>   message='You will be able to login when you receive another 
> email stat
> ing that the registration is completed.'),
>
>
> Also tried
> mail.send(to'['db.auth_user.email'],
>
> in both cases the To: field gets populated with exactly those fields,
>
> To: newuser  or To: db.auth_user.email
>
> How do I access this variable please?
>
> I don't see an example in the book or the cookbook, or in the web2py-users 
> group
> that explains in a way I understand.
>
> thanks for any help,
> Margaret
>
>

--