You need to code a simple function that sends the email (better would be to
queue them and send them asynchronously).
There's nothing "embedded" in web2py ready to use for that kind of
functionality.....
def app_log(message):
mail.send(to=['[email protected]'],
subject='event happened',
message=message)
Then, you can do wherever you need in your code
app_log('something happened')
But that would slow response times because the mail is sent synchronously.
Better to use the scheduler for that. In addition to the app_log()
function, just define in a model file
def queue_log(message):
mysched.queue_task(app_log, [message])
from gluon.scheduler import Scheduler
mysched = Scheduler(db)
Now, in your app, use
queue_log('something happened')
Mail sending will be queued. To activate the queue processing, just start
web2py.py -K yourappname
as another process. It will periodically check for queued tasks (your
emails) and send them without slowing down your response times.
--