Class email

Description

email class A class which encapsulates all the functions required to compose and send an e-mail message. Also caters for MIME attachments.

Located in /mail-defs.php (line 85)


	
			
Variable Summary
 mixed $base64_func
 mixed $bcc
 mixed $body
 mixed $cc
 mixed $charset
 mixed $content
 mixed $errors
 mixed $from
 mixed $mimeparts
 mixed $qp_func
 mixed $replyto
 mixed $subject
 mixed $to
Method Summary
 email email ([string $from = ""], [string $to = ""], [string $subject = ""], [string $body = ""], [string $headers = ""], [string $mimecontenttype = CONTENT_TEXT], [string $mimeboundary = ""])
 void add_content (string $content)
 void add_header (string $header)
 void attach (string $data, [mixed $description = ""], [string $contenttype = CONTENT_OCTET], [string $encoding = ENC_BASE64], [string $disp = ""])
 void attach_file (string $path, [mixed $description = ""], [string $contenttype = CONTENT_OCTET], [string $encoding = ENC_BASE64], [string $disp = ""])
 void attach_html (string $data, [string $encoding = ENC_BASE64])
 void Bcc (string $bcc)
 void Body (string $body)
 void Cc (string $cc)
 void charset (string $charset_code)
 string error_message ()
 void extra_header (string $headername, string $headervalue)
 void From (string $from)
 void printable ([string $format = "text"])
 void ReplyTo (string $replyto)
 boolean send ([string $mimecontenttype = ""], [string $charset = ""])
 void Subject (string $subject)
 void To (string $to)
Variables
mixed $base64_func = "" (line 118)

If !specified use PHP's base64

mixed $bcc = array() (line 94)

Bcc: (blind copies to) header

mixed $body = "" (line 100)

e-mail body text

mixed $cc = array() (line 92)

Cc: (copies to) header

mixed $charset = DEFAULT_CHARSET (line 133)

character set to use for the e-mail

mixed $content = "" (line 124)

E-mail body + headers minus From: and Subject:

mixed $email_headers = array() (line 115)

All e-mail headers end up here, apart from To: This

mixed $errors = array() (line 105)

Accumulated errors

mixed $extra_headers = array() (line 110)

Extra ad-hoc e-mail headers added from external

mixed $from = "" (line 88)

e-mail From address

mixed $mimeboundary = "" (line 130)

MIME boundary marker to use

mixed $mimecontenttype = CONTENT_TEXT (line 127)

MIME content type for the e-mail

mixed $mimeparts = array() (line 136)

Assembled mime attachments

mixed $qp_func = "" (line 121)

None at this time

mixed $replyto = "" (line 96)

e-mail ReplyTo address

mixed $subject = "" (line 98)

Subject of the e-mail

mixed $to = array() (line 90)

Address to send e-mail

Methods
Constructor email (line 149)

Constructor Creates the basic email object.

email email ([string $from = ""], [string $to = ""], [string $subject = ""], [string $body = ""], [string $headers = ""], [string $mimecontenttype = CONTENT_TEXT], [string $mimeboundary = ""])
  • string $from: From: email address
  • string $to: To: email address
  • string $subject: Subject line of the e-mail
  • string $body: Body text of the e-mail
  • string $headers: Extra headers to include for this e-mail
  • string $mimecontenttype: Mime content type
  • string $mimeboundary: Pattern designating mime boundary
add_content (line 269)

Append new content to the body of the email.

void add_content (string $content)
  • string $content: New content to add to the existing email body.
add_header (line 288)

Generic function to add a header. We store our headers in an associative array, keyed on the proper-cased header name, so we avoid duplicates.

  • deprecated: the new function extra_header() is now preferred
void add_header (string $header)
  • string $header: Header to add to e-mail in 'Headername: value' format
attach (line 391)

Wrapper for general binary attachments. We assume a MIME content type of multipart/mixed for these..

void attach (string $data, [mixed $description = ""], [string $contenttype = CONTENT_OCTET], [string $encoding = ENC_BASE64], [string $disp = ""])
  • string $data: The binary data to attach
  • string $contenttype: Mime content type of this attachment
  • string $encoding: Encoding type for this attachment
  • string $disp: Content disposition
attach_file (line 340)

Attaches a 'file' to the e-mail message. Pass a file pathname to attach.

This function returns a success/failure code/key of current attachment in array (+1). @see attach()

void attach_file (string $path, [mixed $description = ""], [string $contenttype = CONTENT_OCTET], [string $encoding = ENC_BASE64], [string $disp = ""])
  • string $path: Path to the file to attach
  • string $contenttype: Mime content type of this attachment
  • string $encoding: Encoding type for this attachment
  • string $disp: Content disposition
attach_html (line 373)

Just a convenient wrapper for adding HTML attachments. Note that with

this call we are assuming that we are going to be sending an e-mail with a plain text and an HTML equivalent. This is why we set the MIME content type to "multipart/alternative" here. This can be over-ridden using the parameter in the send(0 function.

void attach_html (string $data, [string $encoding = ENC_BASE64])
  • string $data: The HTML data to attach
  • string $encoding: Encoding type for this attachment
Bcc (line 244)

Set blind copies-to Set the e-mail Bcc: e-mail addresses for blind copies to.

The supplied e-mail addresses can be a comma-delimited list. NB: Every time this method is called, addresses are appended.

void Bcc (string $bcc)
  • string $bcc: List of e-mail addresses to blind copy e-mail to
Body (line 198)

Set body

Set the e-mail body content

void Body (string $body)
  • string $body: Body content for this email
Cc (line 234)

Set copies-to Set the e-mail Cc: e-mail addresses for copies to.

The supplied e-mail addresses can be a comma-delimited list. NB: Every time this method is called, addresses are appended.

void Cc (string $cc)
  • string $cc: List of e-mail addresses to copy e-mail to
charset (line 276)

Set the character set encoding for the email.

void charset (string $charset_code)
  • string $charset_code: Code of the characterset to use for the email
error_message (line 569)

Return error messages. These may have accumulated during the email assembly or during the send process.

  • return: Error message(s) which have accumulated.
string error_message ()
extra_header (line 304)

Generic method to add an extra header. This method is now preferred over the depreceted 'add_header()' method above. We store our headers in an associative array, keyed on the proper-cased header name.

void extra_header (string $headername, string $headervalue)
  • string $headername: Name of the Header to add in this build
  • string $headervalue: Value of the Header to add in this build
From (line 206)

Set from Set the e-mail From: e-mail addresses.

void From (string $from)
  • string $from: e-mail address e-mail comes from
printable (line 546)

Return Printable Content Returns a printable version of the e-mail. Just returns the content as well as all the headers, and if for HTML, then it wraps it all in some (pre) tags. Useful for debugging.

void printable ([string $format = "text"])
  • string $format: Format of output, either 'text' (default) or 'html'
ReplyTo (line 214)

Set replyto Set the e-mail ReplyTo: e-mail address.

void ReplyTo (string $replyto)
  • string $replyto: e-mail address recipient replies to
send (line 587)

Send the email Send mail via local mailer. This is usually the end-result of an e-mail sequence and results in the e-mail being sent.

  • return: True if email was sent successfully
boolean send ([string $mimecontenttype = ""], [string $charset = ""])
  • string $mimecontenttype: Override for the email MIME content type
  • string $charset: Override for the email character set
Subject (line 190)

Set subject

Set the e-mail Subject: header

void Subject (string $subject)
  • string $subject: Subject for this email
To (line 224)

Set to Set the e-mail To: e-mail addresses.

The supplied e-mail addresses can be a comma-delimited list. NB: Every time this method is called, addresses are appended.

void To (string $to)
  • string $to: List of e-mail addresses to send e-mail to

Documentation generated by phpDocumentor 1.3.0RC3