I just modified my tools.py as follows: elif self.settings.server == 'gae': logging.warn("using gae mail server") from google.appengine.api import mail attachments = attachments and [(a.my_filename,a.my_payload) for a in attachments]
## gae mailer chokes on empty attachments or html extra = dict(html=html, attachments=attachments) for k in extra.keys(): if not extra[k]: extra.pop(k) result = mail.send_mail(sender=self.settings.sender, to=to, subject=subject, body=text, **extra) logging.warn("result of mail.send_mail() is %s"%repr(result)) This fixed the exceptions associated with empty attachments and html, but no mail is being sent when testing under GAE Launcher, apparently because something else needs to be done to enable it. Here's what's showing up in the console log: WARNING 2010-07-11 15:57:04,413 tools.py:535] using gae mail server INFO 2010-07-11 15:57:04,416 mail_stub.py:84] MailService.Send INFO 2010-07-11 15:57:04,416 mail_stub.py:85] From: myaddr...@gmail.com INFO 2010-07-11 15:57:04,416 mail_stub.py:88] To: myaddr...@gmail.com INFO 2010-07-11 15:57:04,416 mail_stub.py:97] Subject: Email verification INFO 2010-07-11 15:57:04,416 mail_stub.py:100] Body: INFO 2010-07-11 15:57:04,416 mail_stub.py:101] Content-type: text/plain INFO 2010-07-11 15:57:04,416 mail_stub.py:102] Data length: 132 INFO 2010-07-11 15:57:04,417 mail_stub.py:207] You are not currently sending out real email. If you have sendmail installed you can use it by using the server with --enable_sendmail WARNING 2010-07-11 15:57:04,417 tools.py:545] result of mail.send_mail() is None Since it's the gae server, I'm not sure if the bit about -- enable_sendmail is relevant, but clearly something is not set up correctly. Any ideas? I'm running GAE SDK 1.3.5 and web2py 1.92 on OS X 10.6.4 BTW, I'm wondering if the default registration page should be amended to allow retrying the email notification when attempting to register an unverified address that's already in the db. Having to use the admin interface to delete the address each time while debugging mail settings is time-consuming. Thanks, Mike On Jun 19, 11:12 am, Larry <ziz...@gmail.com> wrote: > Peter, > > This code looks good to me. I will adopt the same for now. > > Larry > > On Jun 19, 12:37 am, pecos1046 <pecos1...@gmail.com> wrote: > > > > > Hi Larry: > > > Looking at your suggestion, I made a code change in tools.py and mail > > with gae works well. Here my patch - so far so good, I wonder when it > > will backfire. > > > elif self.settings.server == 'gae': > > from google.appengine.api import mail > > attachments = attachments and > > [(a.my_filename,a.my_payload) for a in attachments] > > > if attachments and html: > > result = > > mail.send_mail(sender=self.settings.sender, to=to, > > subject=subject, body=text, > > html=html, > > attachments=attachments) > > > elif html: > > result = > > mail.send_mail(sender=self.settings.sender, to=to, > > subject=subject, body=text, > > html=html) > > > elif attachments: > > result = > > mail.send_mail(sender=self.settings.sender, to=to, > > subject=subject, body=text, > > attachments=attachments) > > > else: > > result = > > mail.send_mail(sender=self.settings.sender, to=to, > > subject=subject, body=text) > > > Thanks again > > > Peter > > > On Jun 17, 5:16 am, Larry <ziz...@gmail.com> wrote: > > > > I was also getting thiserroron my first go at sending mail using > > > gae. > > > > I looked at the code in gluon/tools.py for sending gae mail : > > > > elif self.settings.server == 'gae': > > > from google.appengine.api import mail > > > attachments = attachments and [(a.my_filename,a.my_payload) for a > > > in attachments] > > > result = mail.send_mail(sender=self.settings.sender, to=to, > > > subject=subject, body=text, html=html, > > > attachments=attachments) > > > > and retried after removing the attachments=attachments from the > > > send_mail and it worked if I send both text and html versions of the > > > message. > > > > I assume gae does not like the attachments value being None. > > > > Larry > > > > On Jun 11, 9:25 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > if you use server='gae' you should use login=None > > > > Not sure if this is the problem anyway. Do you get anyerror? > > > > > On 11 Giu, 10:12, pecos1046 <pecos1...@gmail.com> wrote: > > > > > > I use theemailverification option for new user registration. It > > > > > works fine in test mode on the google-appengine sdk. However when I > > > > > upload the application to Google and change the smtp server to "gae" > > > > > it is unable to send the verificationemail. The GoogleGAElog show > > > > > the following warning message: > > > > > >Mail.send failure:May not set empty value for 'attachments' > > > > > > Here are my settings: > > > > > >mail=Mail( ) > > > > >mail.settings.server='gae' # your SMTP server > > > > >mail.settings.sender='....@gmail.com' > > > > >mail.settings.tls = True > > > > >mail.settings.login='....@gmail.com:password' > > > > > auth.settings.mailer=mail > > > > > > I appreciate any help and suggestions. > > > > > > Peter