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='[email protected]' # 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=='[email protected]': 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?
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.