This module is a very simple module (the source code is only 20 lines) that allows you to send e-mails from
your CherryPy program.
The module defines an abstract CherryClass called Mail, with one member variable called smtpServer and
one method called sendMail.
To use it, just derive the Mail CherryClass, set smtpServer in the __init__ method, and then
call sendMail to send an e-mail:
- variable: smtpServer
-
String containing the address of the Smtp server
- function: sendMail(sender, receiver, bcc, contentType, subject, msg)
-
This functions sends an e-mail according to the parameters. All parameters must be a string. contentType should be
either "text/plain" or "text/html". Depending on contentType, msg should contain either plain text or html text.
This functions uses Python's smtplib library to send the e-mail. It uses the value of smtpServer to send
the email.
- function: sendHtmlMail(sender, receiver, bcc, subject, txtmsg, htmlmsg)
-
This functions sends an HTML e-mail according to the parameters. All parameters must be a string.
This functions uses Python's smtplib and MimeWriter modules to send the e-mail. It uses the value of smtpServer to send the email.
Exemple:
use Mail
CherryClass MyMail(Mail):
function:
def __init__(self):
self.smtpServer='smtp.site.com'
CherryClass Root:
mask:
def index(self):
<py-exec="myMail.sendMail('me@site.com', 'you@yourhost.com', '', 'text/plain', 'Hello', 'Hello,\nthis is me')">
<html><body>
Hi, I just sent an e-mail to you@yourhost.com
</body></html>
See About this document... for information on suggesting changes.