On Mar 14, 4:18 am, annet <annet.verm...@gmail.com> wrote:
> Hi Denes,
>
> This send_mail function works:
>
> def send_mail():
>
> nfas=db(db.nfa.nfatype==4).select(db.nfa.ALL,orderby=db.nfa.bedrijf)
>     for nfa in nfas:
>         context=dict(nfa=nfa)
>         message=response.render('clublocatormail/
> send_mail.html',context)
>         recipient=nfa.adres
>         mail.send(to=[recipient],subject='Controleer uw adresgegevens
> in Fitwise',message=message)
>     return True
>
> I do have a question though: why recipient=nfa.adres and not
> recipient=nfa[0].adres

because you have
for nfa in nfas:
so each nfa is a record (from the group of records or 'Rows' object
called nfas)

> Furthermore, I don't think this function is very robust. It returns
> True on success, but that's all. What happens when the send function
> returns a False? Shouldn't I keep track of the Trues and Falses the
> send function returns for every mail sent?

You could since mail.send also returns True on success or False on
failure and before returning, it updates two attributes of the mail
object:
1) self.result: return value of smtplib.SMTP.sendmail() or GAE's
mail.send_mail() method
2) self.error: Exception message or None if above was successful
It is up to you to act on that info.

> Kind regards,
>
> Annet

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to