The role of a cron job is to start the same task at periodic time. If
the task takes too long, two or more of such tasks can overlap and
slow thing down.

In your case you have events that trigger the emails. You do not want
to send emails at fixed scheduled time but as soon as possible if not
busy sending another email. This is not a cron job this is a queue.

You need to implement the queue in a database and start second web2py
process in charge of going through the queue and sending all the
emails. The separate process can be started manually or via the cron
@reboot option.

On Feb 3, 10:08 pm, weheh <richard_gor...@verizon.net> wrote:
> Do you mean a cron job? Or is it a separate service? I was intending
> to make it a service, however I wanted to try this out to see if it
> would work. I know for a fact that my mail server is functioning. I
> have an old app written in python that does an SMTP-based mailing
> using mail.server 127.0.0.1. I tried that with web2py but it didn't
> work.
>
> On Feb 3, 10:17 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > You need a background process and database queue of tasks for this to
> > work well.
>
> > On Feb 3, 8:50 pm, weheh <richard_gor...@verizon.net> wrote:
>
> > > I tried the mail.settings.server='localhost:25' but still no results.
>
> > > As for Russel's comment, ultimately I intend to loop on a db of
> > > possibly thousands of users. I intend to put some pause between user
> > > emails in order to not trip spam filters. Do you anticipate a problem
> > > from that configuration?
>
> > > As for the for loop in my test case, it's only looking to email to me,
> > > for the time being (hence the if not me: continue statement). Now, the
> > > message.html file is under /web2py/applications/myapp/views/admin/
> > > message.html. Is that the correct place to put it?
>
> > > On Feb 3, 10:36 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > Can you try?
>
> > > > mail.settings.server='localhost:25'
>
> > > > On Feb 3, 12:02 am, weheh <richard_gor...@verizon.net> wrote:
>
> > > > > I'm trying to get the email module to work. In my model I say:
>
> > > > > #model
> > > > > mail.settings.server='localhost'            # your SMTP server
> > > > > mail.settings.login=None                    # your credentials
> > > > > mail.settings.sender='no-re...@foobar.com'  # your email
>
> > > > > #controller "admin.py"
> > > > > def email_blast():
> > > > >   """Controller for sending email blasts to filtered user lists"""
> > > > >   # set up crud
> > > > >   crud.settings.create_onaccept=lambda form: send_email(form)
> > > > >   crud.settings.update_onaccept=lambda form: None
> > > > >   # build crud form
> > > > >   form = crud.update(db.email_blast,request.args(2),message=T('Blast
> > > > > sent'))
> > > > >   # build record table
> > > > >   rows=crud.select(db.email_blast)
> > > > >   return dict(form=form,rows=rows)
>
> > > > > def send_email(form):
> > > > >   """Function sends email to all users that match query"""
> > > > >   for user in db(db.auth_user.id>0).select():
> > > > >     if not user.email=='testa...@foobar.com': continue
> > > > >     context=dict(user=user)
> > > > >     #if form.vars.approved:
> > > > >     message = response.render('admin/message.html',context)
> > > > >     mail.send(to=
> > > > > [user.email],subject=form.vars.subject,message=message)
>
> > > > > Mine is the test email address (real address in actual code). But I'm
> > > > > never getting any email.
>
> > > > > My server is up and running OK and an old email program that I also
> > > > > wrote that uses localhost is working fine.
>
> > > > > Any ideas where I'm going wrong?- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
>
>

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