--- a/iro/offer/smtp.py Sun Mar 25 20:11:34 2012 +0200
+++ b/iro/offer/smtp.py Sun Mar 25 20:14:35 2012 +0200
@@ -21,6 +21,12 @@
from .provider import Provider, providers
class SMTP(Provider):
+ """A SMTP Provider to send emails.
+ This Provider has only one typ ``"mail"`` and one route ``None``.
+
+ If :attr:`~iro.offer.provider.Provider.testmode` is **True** no mail will be send, only a connection is created to server.
+
+ """
def __init__(self, name):
Provider.__init__(self,name,{"mail":[None]})
self.options.update({
@@ -35,6 +41,14 @@
self.order.extend(["host","port","user","password","SSL","TLS","send_from"])
def send(self, recipient, mail):
+ """sends a mail to recipient
+
+ :param string recipient: A valid email address.
+ :param `iro.model.message.Mail` mail: Mail to send.
+ :return:
+ - All went ok -- :class:`iro.model.status.Status` object
+ - otherwise -- an exception
+ """
if not self.testmode:
if self.SSL:
smtp = smtplib.SMTP_SSL(self.host,self.port)
@@ -54,7 +68,7 @@
tmpmail=copy.deepcopy(mail)
tmpmail.content['From'] = frm
- tmpmail.content['To']=recipient
+ tmpmail.content['To'] = recipient
if not self.testmode:
smtp.sendmail(frm, recipient, tmpmail.as_string())
return Status(self, None)
@@ -62,6 +76,8 @@
smtp.quit()
def getSendFunc(self, typ, route):
+ """returns :meth:`send` method, if typ and route is valid."""
+
Provider.getSendFunc(self, typ, route)
return self.send