Package twisted :: Package protocols :: Module smtp
[frames | no frames]

Module twisted.protocols.smtp

Simple Mail Transfer Protocol implementation.
Classes
Address Parse and hold an RFC 2821 address.
ESMTP  
ESMTPClient  
IMessage Interface definition for messages that can be sent via SMTP.
IMessageDelivery  
IMessageDeliveryFactory An alternate interface to implement for handling message delivery.
SMTP SMTP server-side protocol.
SMTPClient SMTP client for sending emails.
SMTPFactory Factory for SMTP.
SMTPSender Utility class for sending emails easily - use with SMTPSenderFactory.
SMTPSenderFactory Utility factory for sending emails easily.
User Hold information about and SMTP message recipient, including information on where the message came from
xtextStreamReader  
xtextStreamWriter  

Exceptions
AddressError Parse error in address
SMTPAddressError  
SMTPBadRcpt  
SMTPBadSender  
SMTPClientError  
SMTPConnectError  
SMTPDeliveryError  
SMTPError  
SMTPProtocolError  
SMTPServerError  

Function Summary
  idGenerator()
  messageid(uniq, N)
Return a globally unique random string in RFC 2822 Message-ID format
  quoteaddr(addr)
Turn an email address, possibly with realname part etc, into a form suitable for and SMTP envelope.
  rfc822date(timeinfo, local)
Format an RFC-2822 compliant date string.
Deferred sendEmail(smtphost, fromEmail, toEmail, content, headers, attachments, multipartbody)
Send an email, optionally with attachments.
Deferred sendmail(smtphost, from_addr, to_addrs, msg)
Send an email
  xtext_codec(name)
  xtext_decode(s)
  xtext_encode(s)

Variable Summary
str atom = "[-A-Za-z0-9!\\#$%&'*+/=?^_`{|}~]"
str AUTH = 'AUTH'
str COMMAND = 'COMMAND'
str DATA = 'DATA'
dict SUCCESS = {256: None, 257: None, 258: None, 259: None, 2...

Function Details

messageid(uniq=None, N=<method-wrapper object at 0x846c8b4>)

Return a globally unique random string in RFC 2822 Message-ID format

<datetime.pid.random@host.dom.ain>

Optional uniq string will be added to strenghten uniqueness if given.

quoteaddr(addr)

Turn an email address, possibly with realname part etc, into a form suitable for and SMTP envelope.

rfc822date(timeinfo=None, local=1)

Format an RFC-2822 compliant date string.
Parameters:
timeinfo - (optional) A sequence as returned by time.localtime() or time.gmtime(). Default is now.
local - (optional) Indicates if the supplied time is local or universal time, or if no time is given, whether now should be local or universal time. Default is local, as suggested (SHOULD) by rfc-2822.
Returns:
A string representing the time and date in RFC-2822 format.

sendEmail(smtphost, fromEmail, toEmail, content, headers=None, attachments=None, multipartbody='mixed')

Send an email, optionally with attachments.
Parameters:
smtphost - hostname of SMTP server to which to connect
           (type=str)
fromEmail - email address to indicate this email is from
           (type=str)
toEmail - email address to which to send this email
           (type=str)
content - The body if this email.
           (type=str)
headers - Dictionary of headers to include in the email
           (type=dict)
attachments - Each 3-tuple should consist of the name of the attachment, the mime-type of the attachment, and a string that is the attachment itself.
           (type=list of 3-tuples)
multipartbody - The type of MIME multi-part body. Generally either "mixed" (as in text and images) or "alternative" (html email with a fallback to text/plain).
           (type=str)
Returns:
The returned Deferred has its callback or errback invoked when the mail is successfully sent or when an error occurs, respectively.
           (type=Deferred)

sendmail(smtphost, from_addr, to_addrs, msg)

Send an email

This interface is intended to be a direct replacement for smtplib.SMTP.sendmail() (with the obvious change that you specify the smtphost as well). Also, ESMTP options are not accepted, as we don't do ESMTP yet. I reserve the right to implement the ESMTP options differently.
Parameters:
smtphost - The host the message should be sent to
from_addr - The (envelope) address sending this mail.
to_addrs - A list of addresses to send this mail to. A string will be treated as a list of one address
msg - The message, including headers, either as a file or a string. File-like objects need to support read() and close(). Line endings must be local (i.e. '\n'). If you pass something that doesn't look like a file, we try to convert it to a string (so you should be able to pass an email.Message directly, but doing the conversion with email.Generator manually will give you more control over the process).
Returns:

A Deferred, its callback will be called if a message is sent to ANY address, the errback if no message is sent.

The callback will be called with a tuple (numOk, addresses) where numOk is the number of successful recipient addresses and addresses is a list of tuples (address, code, resp) giving the response to the RCPT command for each address.
           (type=Deferred)

Variable Details

atom

Type:
str
Value:
"[-A-Za-z0-9!\\#$%&'*+/=?^_`{|}~]"                                     

AUTH

Type:
str
Value:
'AUTH'                                                                 

COMMAND

Type:
str
Value:
'COMMAND'                                                              

DATA

Type:
str
Value:
'DATA'                                                                 

SUCCESS

Type:
dict
Value:
{256: None,
 257: None,
 258: None,
 259: None,
 260: None,
 261: None,
 262: None,
 263: None,
...                                                                    

Generated by Epydoc 2.0 on Sat May 15 20:08:18 2004 http://epydoc.sf.net