Class IMP_Compose

Description

The IMP_Compose:: class contains functions related to generating outgoing mail messages.

$Horde: imp/lib/Compose.php,v 1.107.2.89 2009/11/05 10:30:54 jan Exp $

Copyright 2002-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (GPL). If you did not receive this file, see http://www.fsf.org/copyleft/gpl.html.

Located in /lib/Compose.php (line 30)


	
			
Variable Summary
 integer $_atcid
 boolean $_attachVCard
 string $_bodyCharset
 array $_cache
 string $_cacheid
 integer $_draftIdx
 boolean $_findhtml
 boolean $_linkAttach
 string $_mimeid
 boolean $_resume
 integer $_size
Method Summary
 boolean addFilesFromUpload (string $field, [string $disp = null], [boolean $notify = false])
 PEAR_Error addMIMEPartAttachment (MIME_Part &$part)
 mixed addUploadAttachment (string $name, string $disposition)
 array attachFilesFromMessage (IMP_Contents &$contents, [boolean $download = false])
 void attachIMAPMessage (mixed $indices, array &$header)
 void attachVCard (boolean $attach, string $name)
 boolean buildAndSendMessage (string $message, array $header, string $charset, boolean $html, [array $opts = array()])
 MIME_Part buildAttachment (integer $id)
 MIME_Part convertToMultipartRelated (MIME_Part $mime_part)
 array deleteAttachment (mixed $number)
 mixed expandAddresses (string $addrString, [boolean $full = false], [boolean $include = true])
 string findBody (IMP_Contents &$imp_contents)
 string formatAddr (string $addr)
 array forwardMessage ( &$imp_contents, [string $forcebodytxt = false], IMP_Contents $imp_contents)
 array getAttachments ()
 string getBodyCharset (IMP_Contents &$imp_contents)
 string getBodyId (IMP_Contents &$imp_contents)
 string getHTMLBody (IMP_Contents &$imp_contents)
 MIME_Part getMessageBody (string $message, string $charset, boolean $html, [string $final_msg = true])
 string getMessageCacheId ()
 MIME_Part linkAttachments (string $baseurl, MIME_Part $base_part, string $auth)
 integer maxAttachmentSize ()
 integer numberOfAttachments ()
 void pgpAttachPubkey (boolean $attach)
 array recipientList (array $hdr, [boolean $exceed = true])
 array replyMessage (string $actionID,  &$imp_contents, [string $to = null], IMP_Contents $imp_contents)
 array resumeDraft (string $index)
 string rfc822WriteGroupAddress (string $groupname, [array $addresses = array()])
 mixed saveDraft ( $headers, mixed $message, string $charset, boolean $html, array $header)
 integer saveDraftIndex ()
 mixed sendMessage (string $email, IMP_Headers &$headers, mixed &$message, string $charset)
 IMP_Compose &singleton ([string $cacheid = null])
 integer sizeOfAttachments ()
 string text2html (string $msg)
 void updateAttachment (integer $number, array $params)
 void userLinkAttachments (boolean $attach)
 void _addReferences (MIME_Headers &$headers, array $header)
Variables
integer $_atcid = 0 (line 101)

Internal ID for attachments.

boolean $_attachVCard = false (line 73)

Whether the user's vCard should be attached to outgoing messages.

string $_bodyCharset (line 51)

The "cached" charset of the body MIME part.

array $_cache = array() (line 37)

The cached attachment data.

string $_cacheid (line 108)

The cache ID used to store object in session.

integer $_draftIdx (line 87)

The UID of the last draft saved via saveDraft().

boolean $_findhtml = false (line 94)

In findBody(), indicate we want to return a text/html part.

boolean $_linkAttach = false (line 80)

Whether attachments should be linked.

string $_mimeid = null (line 44)

For findBody, the MIME ID of the "body" part.

boolean $_pgpAttachPubkey = false (line 66)

Whether the user's PGP public key should be attached to outgoing messages.

boolean $_resume = false (line 115)

Are we resuming a message?

integer $_size = 0 (line 58)

The aggregate size of all attachments (in bytes).

Methods
addFilesFromUpload (line 2947)

Add uploaded files from form data.

  • return: Returns false if any file was unsuccessfully added.
  • since: IMP 4.2
boolean addFilesFromUpload (string $field, [string $disp = null], [boolean $notify = false])
  • string $field: The field prefix (numbering starts at 1).
  • string $disp: The prefix for a file disposition input (numbering starts at 1).
  • boolean $notify: Add a notification message for each successful attachment?
additionalAttachmentsAllowed (line 2457)

How many more attachments are allowed?

  • return: Returns true if no attachment limit. Else returns the number of additional attachments allowed.
mixed additionalAttachmentsAllowed ()
addMIMEPartAttachment (line 2097)

Adds an attachment to a MIME_Part from data existing in the part.

  • return: Returns a PEAR_Error object on error.
PEAR_Error addMIMEPartAttachment (MIME_Part &$part)
  • MIME_Part &$part: The MIME_Part object that contains the attachment data.
addUploadAttachment (line 2027)

Adds an attachment to a MIME_Part from an uploaded file.

The actual attachment data is stored in a separate file - the MIME_Part information entries 'temp_filename' and 'temp_filetype' are set with this information.

  • return: Returns the filename on success. Returns PEAR_Error on error.
mixed addUploadAttachment (string $name, string $disposition)
  • string $name: The input field name from the form.
  • string $disposition: The disposition to use for the file.
attachFilesFromMessage (line 2497)

Adds attachments from the IMP_Contents object to the message.

  • return: An array of PEAR_Error object on error. An empty array if successful.
array attachFilesFromMessage (IMP_Contents &$contents, [boolean $download = false])
  • IMP_Contents &$contents: An IMP_Contents object.
  • boolean $download: Use the algorithm in IMP_Contents::getDownloadAllList() to determine the list of attachments?
attachIMAPMessage (line 1901)

Add mail message(s) from the mail server as a message/rfc822 attachment.

void attachIMAPMessage (mixed $indices, array &$header)
  • mixed $indices: See IMP::parseIndicesList().
  • array &$header: Message headers array.
attachVCard (line 2906)

Attach the user's vCard to every message sent by buildAndSendMessage().

  • since: IMP 4.2.1
void attachVCard (boolean $attach, string $name)
  • boolean $attach: True if vCard should be attached.
  • string $name: The user's name.
buildAndSendMessage (line 601)

Builds and sends a MIME message.

  • return: Whether the sent message has been saved in the sent-mail folder, or a PEAR_Error on failure.
boolean buildAndSendMessage (string $message, array $header, string $charset, boolean $html, [array $opts = array()])
  • string $message: The message body.
  • array $header: List of message headers.
  • string $charset: The sending charset.
  • boolean $html: Whether this is an HTML message.
  • array $opts: An array of options w/the following keys:
     'save_sent' = (bool) Save sent mail?
     'sent_folder' = (string) The sent-mail folder.
     'save_attachments' = (bool) Save attachments with the message?
     'reply_type' = (string) What kind of reply this is (reply or forward).
     'reply_index' = (string) The IMAP message mailbox/index of the message
                     we are replying to. The index should be in
                     IMP::parseIndicesList() format #1.
     'encrypt' => (integer) A flag whether to encrypt or sign the message.
                  One of IMP_PGP_ENCRYPT, IMP_PGP_SIGNENC,
                  IMP_SMIME_ENCRYPT, or IMP_SMIME_SIGNENC.
     'priority' => (integer) The message priority from 1 to 5.
     'readreceipt' => (bool) Add return receipt headers?
     'useragent' => (string) The User-Agent string to use.
buildAttachment (line 2311)

Build a single attachment part with its data.

  • return: The MIME_Part with its contents.
MIME_Part buildAttachment (integer $id)
  • integer $id: The ID of the part to rebuild.
convertToMultipartRelated (line 2531)

Convert a text/html MIME_Part message with embedded image links to a multipart/related MIME_Part with the image data embedded in the part.

  • return: The modified MIME_Part.
MIME_Part convertToMultipartRelated (MIME_Part $mime_part)
  • MIME_Part $mime_part: The text/html MIME_Part object.
deleteAllAttachments (line 2253)

Deletes all attachments.

void deleteAllAttachments ()
deleteAttachment (line 2210)

Delete attached files.

  • return: The list of deleted filenames (MIME encoded).
array deleteAttachment (mixed $number)
  • mixed $number: Either a single integer or an array of integers corresponding to the attachment position.
expandAddresses (line 2697)

Uses the Registry to expand names and return error information for any address that is either not valid or fails to expand.

This method can be called statically, i.e.: $ret = IMP_Compose::expandAddresses()

  • return: Either a string containing all expanded addresses or an array containing all matching address or an error object.
mixed expandAddresses (string $addrString, [boolean $full = false], [boolean $include = true])
  • string $addrString: The name(s) or address(es) to expand.
  • boolean $full: If true generate a full, rfc822-valid address list.
  • boolean $include: Include the original search term if it is a valid address?
findBody (line 1484)

Finds the main "body" text part (if any) in a message.

  • return: The text of the "body" part of the message. Returns an empty string if no "body" found.
string findBody (IMP_Contents &$imp_contents)
formatAddr (line 400)

Formats the address properly.

Can be called statically.

  • return: The formatted address.
string formatAddr (string $addr)
  • string $addr: The address to format.
forwardMessage (line 1790)

Determine the text and headers for a forwarded message.

  • return: An array with the following keys:
     'body'     - The text of the body part
     'headers'  - The headers of the message to use for the reply
     'format'   - The format of the body message
     'identity' - The identity to use for the reply based on the original
                  message's addresses.
array forwardMessage ( &$imp_contents, [string $forcebodytxt = false], IMP_Contents $imp_contents)
  • IMP_Contents $imp_contents: An IMP_Contents object.
  • string $forcebodytxt: Force addition of body text, even if prefs would not allow it.
  • &$imp_contents
getAttachments (line 2279)

Returns the list of current attachments.

  • return: The list of attachments.
array getAttachments ()
getBodyCharset (line 1588)

Returns the charset of the MIME part containing the "body".

  • return: The charset of the mime part's body.
string getBodyCharset (IMP_Contents &$imp_contents)
getBodyId (line 1573)

Returns the ID of the MIME part containing the "body".

  • return: The ID of the mime part's body.
string getBodyId (IMP_Contents &$imp_contents)
getHTMLBody (line 1529)

Returns the HTML body text of a message.

The HTML code is passed through the XSS filter and any tags outside and including the body and html tags are removed.

  • return: The HTML text of the message. Returns an empty string if no "body" found.
string getHTMLBody (IMP_Contents &$imp_contents)
getMessageBody (line 425)

Gets the message body and sets up the MIME parts.

  • return: The body as a MIME object, or PEAR_Error on error.
MIME_Part getMessageBody (string $message, string $charset, boolean $html, [string $final_msg = true])
  • string $message: The raw message body.
  • string $charset: The charset to use.
  • boolean $html: Whether this is an HTML message.
  • string $final_msg: Whether this is a message which will be sent out.
getMessageCacheId (line 2445)

Obtains the cache ID for the session object.

  • return: The message cache ID.
string getMessageCacheId ()
linkAttachments (line 2624)

Remove all attachments from an email message and replace with urls to downloadable links. Should properly save all attachments to a new folder and remove the MIME_Parts for the attachments.

  • return: Modified part with links to attachments. Returns PEAR_Error on error.
MIME_Part linkAttachments (string $baseurl, MIME_Part $base_part, string $auth)
  • string $baseurl: The base URL for creating the links.
  • MIME_Part $base_part: The body of the message.
  • string $auth: The authorized user who owns the attachments.
maxAttachmentSize (line 2473)

What is the maximum attachment size allowed?

  • return: The maximum attachment size allowed (in bytes).
integer maxAttachmentSize ()
numberOfAttachments (line 2289)

Returns the number of attachments currently in this message.

  • return: The number of attachments in this message.
integer numberOfAttachments ()
pgpAttachPubkey (line 2893)

Attach the user's PGP public key to every message sent by buildAndSendMessage().

  • since: IMP 4.2
void pgpAttachPubkey (boolean $attach)
  • boolean $attach: True if public key should be attached.
recipientList (line 1187)

Cleans up and returns the recipient list. Encodes all e-mail addresses with IDN domains.

  • return: PEAR_Error on error, or an array with the following entries:
     'list' - An array of recipient addresses.
     'header' - An array containing the cleaned up 'to', 'cc', and 'bcc'
                header strings.
array recipientList (array $hdr, [boolean $exceed = true])
  • array $hdr: An array of MIME headers. Recipients will be extracted from the 'to', 'cc', and 'bcc' entries.
  • boolean $exceed: Test if user has exceeded the allowed number of recipients?
replyMessage (line 1614)

Determines the reply text and headers for a message.

  • return: An array with the following keys:
     'body'     - The text of the body part
     'headers'  - The headers of the message to use for the reply
     'format'   - The format of the body message
     'identity' - The identity to use for the reply based on the original
                  message's addresses.
array replyMessage (string $actionID,  &$imp_contents, [string $to = null], IMP_Contents $imp_contents)
  • string $actionID: The reply action (reply, reply_all, reply_list or *).
  • IMP_Contents $imp_contents: An IMP_Contents object.
  • string $to: The recipient of the reply. Overrides the automatically determined value.
  • &$imp_contents
resumeDraft (line 297)

Resumes a previously saved draft message.

  • return: PEAR_Error on error, or an array with the following keys:
     'msg' -- The message text.
     'mode' -- 'html' or 'text'.
     'header' -- A list of headers to add to the outgoing message.
     'identity' -- The identity used to create the message.
array resumeDraft (string $index)
  • string $index: The IMAP message mailbox/index. The index should be in IMP::parseIndicesList() format #1.
rfc822WriteGroupAddress (line 1305)

Write an RFC822 group, given the group name and a list of valid, mailbox+host-only email addresses.

  • return: The correctly quoted group
  • TODO: Add this to Horde_Mime
string rfc822WriteGroupAddress (string $groupname, [array $addresses = array()])
  • string $groupname: The name of the group.
  • array $addresses: The component email addresses.
saveDraft (line 183)

Saves a message to the draft folder.

  • return: Notification text on success, PEAR_Error on error.
mixed saveDraft ( $headers, mixed $message, string $charset, boolean $html, array $header)
  • array $header: List of message headers.
  • mixed $message: Either the message text (string) or a MIME_Message object that contains the text to send.
  • string $charset: The charset that was used for the headers.
  • boolean $html: Whether this is an HTML message.
  • $headers
saveDraftIndex (line 278)

Returns the UID of the last message saved via saveDraft().

  • return: An IMAP UID.
  • since: IMP 4.2
integer saveDraftIndex ()
sendMessage (line 893)

Sends a message.

  • return: True on success, PEAR_Error on error.
mixed sendMessage (string $email, IMP_Headers &$headers, mixed &$message, string $charset)
  • string $email: The e-mail list to send to.
  • IMP_Headers &$headers: The IMP_Headers object holding this message's headers.
  • mixed &$message: Either the message text (string) or a MIME_Message object that contains the text to send.
  • string $charset: The charset that was used for the headers.
singleton (line 131)

Attempts to return a reference to a concrete IMP_Compose instance.

If a IMP_Cacheid object exists with the given cacheid, recreate that that object. Else, create a new instance.

This method must be invoked as:

   $imp_compose = &IMP_Compose::singleton([$cacheid]);

  • return: The IMP_Compose object or null.
IMP_Compose &singleton ([string $cacheid = null])
  • string $cacheid: The cache ID string.
sizeOfAttachments (line 2299)

Returns the size of the attachments in bytes.

  • return: The size of the attachments (in bytes).
integer sizeOfAttachments ()
text2html (line 3001)

Shortcut function to convert text -> HTML for purposes of composition.

  • return: HTML text.
  • since: IMP 4.2
string text2html (string $msg)
  • string $msg: The message text.
updateAttachment (line 2268)

Updates information in a specific attachment.

void updateAttachment (integer $number, array $params)
  • integer $number: The attachment to update.
  • array $params: An array of update information.
     'disposition'  --  The Content-Disposition value.
     'description'  --  The Content-Description value.
userLinkAttachments (line 2929)

Has user specifically asked attachments to be linked in outgoing messages?

  • since: IMP 4.2
void userLinkAttachments (boolean $attach)
  • boolean $attach: True if attachments should be linked.
_addReferences (line 869)

Add necessary headers for replies.

void _addReferences (MIME_Headers &$headers, array $header)
  • MIME_Headers &$headers: The object holding this message's headers.
  • array $header: List of message headers.

Documentation generated on Sun, 30 Jan 2011 05:28:10 +0000 by phpDocumentor 1.4.3