PRFC822Channel Class Reference

#include <inetmail.h>

Inheritance diagram for PRFC822Channel:

PIndirectChannel PChannel PObject List of all members.

Public Types

 Sending
 Receiving
enum  Direction { Sending, Receiving }

Public Member Functions

 PRFC822Channel (Direction direction)
 ~PRFC822Channel ()
PBoolean Close ()
virtual PBoolean Write (const void *buf, PINDEX len)
void NewMessage (Direction direction)
PString MultipartMessage ()
PBoolean MultipartMessage (const PString &boundary)
void NextPart (const PString &boundary)
void SetFromAddress (const PString &fromAddress)
void SetToAddress (const PString &toAddress)
void SetCC (const PString &ccAddress)
void SetBCC (const PString &bccAddress)
void SetSubject (const PString &subject)
void SetContentType (const PString &contentType)
void SetContentAttachment (const PFilePath &filename)
void SetTransferEncoding (const PString &encoding, PBoolean autoTranslate=PTrue)
void SetHeaderField (const PString &name, const PString &value)
PBoolean SendWithSMTP (const PString &hostname)
PBoolean SendWithSMTP (PSMTPClient *smtp)

Static Public Member Functions

static const PStringMimeVersionTag ()
static const PStringFromTag ()
static const PStringToTag ()
static const PStringCCTag ()
static const PStringBCCTag ()
static const PStringSubjectTag ()
static const PStringDateTag ()
static const PStringReturnPathTag ()
static const PStringReceivedTag ()
static const PStringMessageIDTag ()
static const PStringMailerTag ()
static const PStringContentTypeTag ()
static const PStringContentDispositionTag ()
static const PStringContentTransferEncodingTag ()

Protected Member Functions

PBoolean OnOpen ()

Protected Attributes

PBoolean writeHeaders
PMIMEInfo headers
PBoolean writePartHeaders
PMIMEInfo partHeaders
PStringList boundaries
PBase64base64

Detailed Description

A channel for sending/receiving RFC822 compliant mail messages. This encpsulates all that is required to send an RFC822 compliant message via another channel. It automatically adds/strips header information from the stream so the Read() and Write() functions only deal with the message body. For example to send a message using the SMTP classes:

      PSMTPClient mail("mailserver");
      if (mail.IsOpen()) {
        PRFC822Channel message;
        message.SetFromAddress("Me@here.com.au");
        message.SetToAddress("Fred@somwhere.com");
        if (message.Open(mail)) {
          if (mail.BeginMessage("Me@here.com.au", "Fred@somwhere.com")) {
            if (!message.Write(myMessageBody))
              PError << "Mail write failed." << endl;
            if (!message.EndMessage())
              PError << "Mail send failed." << endl;
          }
        }
      }
      else
         PError << "Mail conection failed." << endl;
      


Member Enumeration Documentation

enum PRFC822Channel::Direction

Enumerator:
Sending 
Receiving 


Constructor & Destructor Documentation

PRFC822Channel::PRFC822Channel ( Direction  direction  ) 

Construct a RFC822 aware channel.

Parameters:
direction  /< Indicates are sending or receiving a message

PRFC822Channel::~PRFC822Channel (  ) 

Close the channel before destruction.


Member Function Documentation

static const PString& PRFC822Channel::BCCTag (  )  [static]

static const PString& PRFC822Channel::CCTag (  )  [static]

PBoolean PRFC822Channel::Close (  )  [virtual]

Close the channel. This assures that all mime fields etc are closed off before closing the underliying channel.

Reimplemented from PIndirectChannel.

static const PString& PRFC822Channel::ContentDispositionTag (  )  [static]

static const PString& PRFC822Channel::ContentTransferEncodingTag (  )  [static]

static const PString& PRFC822Channel::ContentTypeTag (  )  [static]

static const PString& PRFC822Channel::DateTag (  )  [static]

static const PString& PRFC822Channel::FromTag (  )  [static]

static const PString& PRFC822Channel::MailerTag (  )  [static]

static const PString& PRFC822Channel::MessageIDTag (  )  [static]

static const PString& PRFC822Channel::MimeVersionTag (  )  [static]

PBoolean PRFC822Channel::MultipartMessage ( const PString boundary  ) 

Enter multipart MIME message mode. This indicates that the message, or individual part within a message as MIME is nestable, is a multipart message. In this form the user supplies a boundary indicator string which must then be used in all subsequent NextPart() calls.

Note this must be called before any writes are done to the message or part.

PString PRFC822Channel::MultipartMessage (  ) 

Enter multipart MIME message mode. This indicates that the message, or individual part within a message as MIME is nestable, is a multipart message. This form returns the boundary indicator string generated internally which must then be used in all subsequent NextPart() calls.

Note this must be called before any writes are done to the message or part.

void PRFC822Channel::NewMessage ( Direction  direction  ) 

Begin a new message. This may be used if the object is to encode 2 or more messages sequentially. It resets the internal state of the object.

Parameters:
direction  Indicates are sending or receiving a message

void PRFC822Channel::NextPart ( const PString boundary  ) 

Indicate that a new multipart message part is to begin. This will close off the previous part, and any nested multipart messages contained therein, and allow a new part to begin.

The user may adjust the parts content type and other header fields after this call and before the first write of the parts body. The default Content-Type is "text/plain".

Note that all header fields are cleared from the previous part.

PBoolean PRFC822Channel::OnOpen (  )  [protected, virtual]

This callback is executed when the Open() function is called with open channels. It may be used by descendent channels to do any handshaking required by the protocol that channel embodies.

The default behaviour is to simply return PTrue.

Returns:
Returns PTrue if the protocol handshaking is successful.

Reimplemented from PIndirectChannel.

static const PString& PRFC822Channel::ReceivedTag (  )  [static]

static const PString& PRFC822Channel::ReturnPathTag (  )  [static]

PBoolean PRFC822Channel::SendWithSMTP ( PSMTPClient smtp  ) 

Send this message using an SMTP socket. This assumes PSMTPClient is open the sends the message to the remote SMTP server.

PBoolean PRFC822Channel::SendWithSMTP ( const PString hostname  ) 

Send this message using an SMTP socket. This will create a PSMTPClient and connect to the specified host then send the message to the remote SMTP server.

void PRFC822Channel::SetBCC ( const PString bccAddress  ) 

Set the Blind Carbon Copy address(es). This must be called before any writes are done to the channel.

Parameters:
bccAddress  Recipients e-mail address (comma separated)

void PRFC822Channel::SetCC ( const PString ccAddress  ) 

Set the Carbon Copy address(es). This must be called before any writes are done to the channel.

Parameters:
ccAddress  Recipients e-mail address (comma separated)

void PRFC822Channel::SetContentAttachment ( const PFilePath filename  ) 

Set the content disposition for attachments. This must be called before any writes are done to the channel. It may be set again immediately after any call to NextPart() when multipart mime is being used.

Note that this will alter the Content-Type field to

Parameters:
filename  Attachment filename

void PRFC822Channel::SetContentType ( const PString contentType  ) 

Set the content type. This must be called before any writes are done to the channel. It may be set again immediately after any call to NextPart() when multipart mime is being used.

The default Content-Type is "text/plain".

Parameters:
contentType  Content type in form major/minor

void PRFC822Channel::SetFromAddress ( const PString fromAddress  ) 

Set the sender address. This must be called before any writes are done to the channel.

Parameters:
fromAddress  Senders e-mail address

void PRFC822Channel::SetHeaderField ( const PString name,
const PString value 
)

Set the and arbitrary header field. This must be called before any writes are done to the channel.

Parameters:
name  MIME fields tag
value  MIME fields contents

void PRFC822Channel::SetSubject ( const PString subject  ) 

Set the message subject. This must be called before any writes are done to the channel.

Parameters:
subject  Subject string

void PRFC822Channel::SetToAddress ( const PString toAddress  ) 

Set the recipient address(es). This must be called before any writes are done to the channel.

Parameters:
toAddress  Recipients e-mail address (comma separated)

void PRFC822Channel::SetTransferEncoding ( const PString encoding,
PBoolean  autoTranslate = PTrue 
)

Set the content transfer encoding. This must be called before any writes are done to the channel. It may be set again immediately after any call to NextPart() when multipart mime is being used.

If the encoding is "base64" (case insensitive) and , all writes will be treated as binary and translated into base64 encoding before output to the underlying channel.

Parameters:
encoding  Encoding type
autoTranslate  Automatically convert to encoding type

static const PString& PRFC822Channel::SubjectTag (  )  [static]

static const PString& PRFC822Channel::ToTag (  )  [static]

virtual PBoolean PRFC822Channel::Write ( const void *  buf,
PINDEX  len 
) [virtual]

Low level write to the channel.

This override assures that the header is written before the body that will be output via this function.

Returns:
PTrue if at least len bytes were written to the channel.
Parameters:
buf  Pointer to a block of memory to write.
len  Number of bytes to write.

Reimplemented from PIndirectChannel.


Member Data Documentation

PBase64* PRFC822Channel::base64 [protected]

PStringList PRFC822Channel::boundaries [protected]

PMIMEInfo PRFC822Channel::headers [protected]

PMIMEInfo PRFC822Channel::partHeaders [protected]

PBoolean PRFC822Channel::writeHeaders [protected]

PBoolean PRFC822Channel::writePartHeaders [protected]


The documentation for this class was generated from the following file:
Generated on Thu May 27 01:36:49 2010 for PTLib by  doxygen 1.4.7