Send email daily depend on SQLFORM date

15 views
Skip to first unread message

Luis Guerra

unread,
May 2, 2016, 3:57:37 PM5/2/16
to web2py-users
Hello, I'm new in Web2py and I need that my site sends an email once per day depend o a due date in a table of my database. I want to send the emails to the email address in the same table.

Best regards,

Luis 

Niphlod

unread,
May 2, 2016, 4:24:19 PM5/2/16
to web2py-users
mail.send() is pretty easy. what's the structure of your "mail" table ?

assuming you have a query for mails ready to be sent, e.g. db((db.mails.send_after > request.now) & (db.mails.sent == False)).select() , all that it takes is

all_mails = db((db.mails.send_after > request.now) & (db.mails.sent == False)).select()
for row in all_mails:
      mail.send(to=row.to, ....)
      row.update_record(row.sent=True)
Reply all
Reply to author
Forward
0 new messages