class PRFC822Channel: public PIndirectChannel

A channel for sending/receiving RFC822 compliant mail messages.

Inheritance:


Public Methods

[more] PRFC822Channel ( Direction direction )
Construct a RFC822 aware channel.
[more] ~PRFC822Channel ()
Close the channel before destruction
[more]BOOL Close ()
Close the channel.
[more]virtual BOOL Write ( const void * buf, PINDEX len )
Low level write to the channel.
[more]void NewMessage ( Direction direction )
Begin a new message.
[more]PString MultipartMessage ()
Enter multipart MIME message mode.
[more]BOOL MultipartMessage ( const PString & boundary )
Enter multipart MIME message mode.
[more]void NextPart ( const PString & boundary )
Indicate that a new multipart message part is to begin.
[more]void SetFromAddress ( const PString & fromAddress )
Set the sender address.
[more]void SetToAddress ( const PString & toAddress )
Set the recipient address(es).
[more]void SetCC ( const PString & ccAddress )
Set the Carbon Copy address(es).
[more]void SetBCC ( const PString & bccAddress )
Set the Blind Carbon Copy address(es).
[more]void SetSubject ( const PString & subject )
Set the message subject.
[more]void SetContentType ( const PString & contentType )
Set the content type.
[more]void SetContentAttachment ( const PFilePath & filename )
Set the content disposition for attachments.
[more]void SetTransferEncoding ( const PString & encoding, BOOL autoTranslate = TRUE )
Set the content transfer encoding.
[more]void SetHeaderField ( const PString & name, const PString & value )
Set the and arbitrary header field.
[more]BOOL SendWithSMTP ( const PString & hostname )
Send this message using an SMTP socket.
[more]BOOL SendWithSMTP ( PSMTPClient * smtp )
Send this message using an SMTP socket.


Inherited from PIndirectChannel:

Public

Construction

Overrides from class PObject

Overrides from class PChannel

Channel establish functions

Protected Fields

oPChannel* readChannel
oBOOL readAutoDelete
oPChannel* writeChannel
oBOOL writeAutoDelete
oPReadWriteMutex channelPointerMutex

Protected Methods

ovirtual BOOL OnOpen()


Inherited from PChannel:

Public Methods

ostatic BOOL ConvertOSError( int libcReturnValue, Errors & lastError, int & osError )

Public

Information functions

Reading functions

Writing functions

Miscellaneous functions

Error functions

Protected Fields

oint os_handle
oErrors lastErrorCode[NumErrorGroups+1]
oint lastErrorNumber[NumErrorGroups+1]
oPINDEX lastReadCount
oPINDEX lastWriteCount
oPTimeInterval readTimeout
oPTimeInterval writeTimeout

Protected Methods

ovirtual BOOL ConvertOSError( int libcReturnValue, ErrorGroup group = LastGeneralError )
oBOOL SetErrorValues( Errors errorCode, int osError, ErrorGroup group = LastGeneralError )
oint ReadCharWithTimeout( PTimeInterval & timeout )


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions


Documentation

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: <PRE><CODE> 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; </PRE></CODE>
o PRFC822Channel( Direction direction )
Construct a RFC822 aware channel.
Parameters:
direction - Indicates are sending or receiving a message

o ~PRFC822Channel()
Close the channel before destruction

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

ovirtual BOOL Write( const void * buf, PINDEX len )
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:
TRUE if at least len bytes were written to the channel.

ovoid 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

oPString 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.

oBOOL 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.

ovoid 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.

ovoid 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

ovoid 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)

ovoid 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)

ovoid 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)

ovoid SetSubject( const PString & subject )
Set the message subject. This must be called before any writes are done to the channel.
Parameters:
subject - Subject string

ovoid 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

ovoid 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

ovoid SetTransferEncoding( const PString & encoding, BOOL autoTranslate = TRUE )
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

ovoid 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

oBOOL 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.

oBOOL SendWithSMTP( PSMTPClient * smtp )
Send this message using an SMTP socket. This assumes PSMTPClient is open the sends the message to the remote SMTP server.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.