Overview of features
Home
Read this first
About
web2py is 100% free
Download
Start learning web2py today
Documentation
Authors and contributors
Staff
Affiliated companies
Support
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
Want to be able to send emails with both plain text and html bodies and even include attachments? Refer to https://mdp.cti.depaul.edu/wiki/default/page/98b7448f-059a-47f7-82da-dce4728aa4dd Using the MultiPart_Mail class documented in the wiki, you can send emails from your controller like this context=dict(name='John Smith', items=['apples','oranges','bananas'], total = 12.75) #use views to help create message bodies message_html=response.render('default/email_template.html',context) message_text = response.render('default/email_template.txt',context) recipients = ['John Smith <John@smith.name>'] subject = "Your Order Has Shipped" #get contents of the files to attach attach1 = _prep_attachment('/path/to/logo.jpg') attach2 = _prep_attachment('/path/to/special_offers.pdf', 'special offers.pdf') for recipient in recipients: status = MimeMail.send(to=recipient, subject=subject, message_text=message_text, message_html=message_html, attachments = [attach1, attach2])