Comments: on this page. Click to read or post your own.

Class Email

Description

Class to support sending emails.

Located in /sapphire/email/Email.php (line 26)

Object
   |
   --ViewableData
      |
      --Email
Direct descendents
Class Description
Member_SignupEmail Class used as template to send an email to new members
Member_ChangePasswordEmail Class used as template to send an email saying that the password has been
Member_ForgotPasswordEmail Class used as template to send the forgot password email
Email_Template Implements an email template that can be populated.
Order_ReceiptEmail This class handles the receipt email which gets sent once an order is made.
Order_StatusEmail This class handles the status email which is sent after changing the attributes in the report (eg. status changed to 'Shipped').
Variable Summary
static mixed $admin_email_address
static mixed $bcc_all_emails_to
static mixed $cc_all_emails_to
static mixed $mailer
static mixed $send_all_emails_to
mixed $attachments
mixed $bcc
mixed $body
mixed $cc
mixed $from
mixed $ss_template
mixed $subject
mixed $to
Method Summary
static void bcc_all_emails_to ( $emailAddress)
static void cc_all_emails_to ( $emailAddress)
static string getAdminEmail ()
static Mailer mailer ()
static string obfuscate (string $email, [string $method = 'visible'])
static void send_all_emails_to ( $emailAddress)
static void setAdminEmail (string $newEmail)
static void set_mailer (Mailer $mailer)
static void validEmailAddress ( $address)
Email __construct ([ $from = null], [ $to = null], [ $subject = null], [ $body = null], [ $bounceHandlerURL = null], [ $cc = null], [ $bcc = null])
void addCustomHeader (string $headerName, string $headerValue)
void attachFile ( $filename, [ $attachedFilename = null], [ $mimetype = null])
void attachFileFromString ( $data,  $filename, [ $mimetype = null])
void BaseURL ()
void Bcc ()
void Body ()
void Cc ()
void debug ()
void From ()
string getTemplate ()
void IsEmail ()
boolean is_valid_address ( $email, string $str)
void parseVariables ([ $isPlain = false])
void populateTemplate ( $data)
bool send ([string $messageID = null])
bool sendPlain ([string $messageID = null])
void setBcc ( $val)
void setBody ( $val)
void setBounceHandlerURL ( $bounceHandlerURL)
void setCc ( $val)
void setFormat ( $format)
void setFrom ( $val)
void setSubject ( $val)
void setTemplate (string $template)
void setTo ( $val)
void Subject ()
void templateData ()
void To ()
Variables
static mixed $admin_email_address = '' (line 124)
static mixed $bcc_all_emails_to = null (line 134)
  • access: protected
static mixed $cc_all_emails_to = null (line 139)
  • access: protected
static mixed $mailer (line 68)
  • access: protected
static mixed $send_all_emails_to = null (line 129)
  • access: protected
mixed $attachments = array() (line 97)
  • access: protected
mixed $bcc (line 63)
  • access: protected
mixed $body (line 47)
  • access: protected

Redefined in descendants as:
mixed $bounceHandlerURL = null (line 118)
  • access: protected
mixed $cc (line 58)
  • access: protected
mixed $customHeaders (line 92)
  • access: protected
mixed $parseVariables_done = false (line 102)
  • access: protected
mixed $plaintext_body (line 53)
  • access: protected
mixed $template_data = null (line 113)
  • access: protected

Inherited Variables

Inherited from ViewableData

ViewableData::$casting
ViewableData::$castingHelperPair_cache
ViewableData::$customisedObj
ViewableData::$failover
ViewableData::$iteratorPos
ViewableData::$iteratorTotalItems
ViewableData::$namedAs
ViewableData::$parent
ViewableData::$_natural_cache
ViewableData::$_object_cache
ViewableData::$_xml_cache

Inherited from Object

Object::$class
Object::$extensions
Object::$extension_instances
Methods
static method bcc_all_emails_to (line 541)

BCC every email generated by the Email class to the given address.

It won't affect the original delivery in the same way that send_all_emails_to does. It just adds a BCC header with the given email address. Note that you can only call this once - subsequent calls will overwrite the configuration variable.

This can be used when you have a system that relies heavily on email and you want someone to be checking all correspondence.

if(Director::isLive()) Email::cc_all_emails_to("supportperson@example.com")

  • access: public
static void bcc_all_emails_to ( $emailAddress)
  • $emailAddress
static method cc_all_emails_to (line 527)

CC every email generated by the Email class to the given address.

It won't affect the original delivery in the same way that send_all_emails_to does. It just adds a CC header with the given email address. Note that you can only call this once - subsequent calls will overwrite the configuration variable.

This can be used when you have a system that relies heavily on email and you want someone to be checking all correspondence.

if(Director::isLive()) Email::cc_all_emails_to("supportperson@example.com")

  • access: public
static void cc_all_emails_to ( $emailAddress)
  • $emailAddress
static method getAdminEmail (line 502)
  • access: public
static string getAdminEmail ()
static method mailer (line 84)

Get the mailer.

static Mailer mailer ()
static method obfuscate (line 589)

Encode an email-address to protect it from spambots.

At the moment only simple string substitutions, which are not 100% safe from email harvesting.

  • todo: Integrate javascript-based solution
  • access: public
static string obfuscate (string $email, [string $method = 'visible'])
  • string $email: Email-address
  • string $method: Method for obfuscating/encoding the address
    • 'direction': Reverse the text and then use CSS to put the text direction back to normal
    • 'visible': Simple string substitution ('@' to '[at]', '.' to '[dot], '-' to [dash])
    • 'hex': Hexadecimal URL-Encoding - useful for mailto: links
static method send_all_emails_to (line 513)

Send every email generated by the Email class to the given address.

It will also add " [addressed to (email), cc to (email), bcc to (email)]" to the end of the subject line This can be used when testing, by putting a command like this in your _config.php file

if(!Director::isLive()) Email::send_all_emails_to("someone@example.com")

  • access: public
static void send_all_emails_to ( $emailAddress)
  • $emailAddress
static method setAdminEmail (line 495)

Used as a default sender address in the Email class unless overwritten. Also shown to users on live environments as a contact address on system error pages.

  • access: public
static void setAdminEmail (string $newEmail)
  • string $newEmail
static method set_mailer (line 75)

This can be used to provide a mailer class other than the default, e.g. for testing.

static void set_mailer (Mailer $mailer)
static method validEmailAddress (line 361)

Validates the email address. Returns true of false

static void validEmailAddress ( $address)
  • $address
Constructor __construct (line 144)

Create a new email.

  • access: public
Email __construct ([ $from = null], [ $to = null], [ $subject = null], [ $body = null], [ $bounceHandlerURL = null], [ $cc = null], [ $bcc = null])
  • $from
  • $to
  • $subject
  • $body
  • $bounceHandlerURL
  • $cc
  • $bcc

Redefinition of:
Object::__construct()

Redefined in descendants as:
addCustomHeader (line 240)

Add a custom header to this value.

Useful for implementing all those cool features that we didn't think of.

  • access: public
void addCustomHeader (string $headerName, string $headerValue)
  • string $headerName
  • string $headerValue
attachFile (line 169)
  • access: public
void attachFile ( $filename, [ $attachedFilename = null], [ $mimetype = null])
  • $filename
  • $attachedFilename
  • $mimetype
attachFileFromString (line 154)
  • access: public
void attachFileFromString ( $data,  $filename, [ $mimetype = null])
  • $data
  • $filename
  • $mimetype
BaseURL (line 249)
  • access: public
void BaseURL ()
Bcc (line 205)
  • access: public
void Bcc ()
Body (line 189)
  • access: public
void Body ()
Cc (line 201)
  • access: public
void Cc ()
debug (line 256)

Debugging help

  • access: public
void debug ()
From (line 197)
  • access: public
void From ()
getTemplate (line 280)
  • access: public
string getTemplate ()
IsEmail (line 304)

Used by SSViewer templates to detect if we're rendering an email template rather than a page template

  • access: public
void IsEmail ()
is_valid_address (line 557)

Checks for RFC822-valid email format.

boolean is_valid_address ( $email, string $str)
  • string $str
  • $email
parseVariables (line 328)

Load all the template variables into the internal variables, including

the template into body. Called before send() or debugSend() $isPlain=true will cause the template to be ignored, otherwise the GenericEmail template will be used and it won't be plain email :)

  • access: protected
void parseVariables ([ $isPlain = false])
  • $isPlain
populateTemplate (line 312)

Populate this email template with values.

This may be called many times.

void populateTemplate ( $data)
  • $data
send (line 429)

Send an email with HTML content.

  • return: Success of the sending operation from an MTA perspective. Doesn't actually give any indication if the mail has been delivered to the recipient properly)
  • see: sendPlain() for sending plaintext emails only.
  • access: public
  • uses: Mailer->sendHTML()
bool send ([string $messageID = null])
  • string $messageID: Optional message ID so the message can be identified in bounces etc.
sendPlain (line 375)

Send the email in plaintext.

  • return: Success of the sending operation from an MTA perspective. Doesn't actually give any indication if the mail has been delivered to the recipient properly)
  • see: send() for sending emails with HTML content.
  • uses: Mailer->sendPlain()
bool sendPlain ([string $messageID = null])
  • string $messageID: Optional message ID so the message can be identified in bounces etc.
setBcc (line 229)
  • access: public
void setBcc ( $val)
  • $val
setBody (line 213)
  • access: public
void setBody ( $val)
  • $val
setBounceHandlerURL (line 162)
  • access: public
void setBounceHandlerURL ( $bounceHandlerURL)
  • $bounceHandlerURL
setCc (line 225)
  • access: public
void setCc ( $val)
  • $val
setFormat (line 181)
  • deprecated: 2.3 Not used anywhere else
  • access: public
void setFormat ( $format)
  • $format
setFrom (line 221)
  • access: public
void setFrom ( $val)
  • $val
setSubject (line 209)
  • access: public
void setSubject ( $val)
  • $val
setTemplate (line 273)

Set template name (without *.ss extension).

  • access: public
void setTemplate (string $template)
  • string $template

Redefined in descendants as:
setTo (line 217)
  • access: public
void setTo ( $val)
  • $val
Subject (line 185)
  • access: public
void Subject ()
templateData (line 284)
  • access: protected
void templateData ()
To (line 193)
  • access: public
void To ()

Inherited Methods

Inherited From ViewableData

ViewableData::ATT_val()
ViewableData::BaseHref()
ViewableData::buildCastingHelperCache()
ViewableData::cachedCall()
ViewableData::castingHelper()
ViewableData::castingHelperPair()
ViewableData::castingObjectCreator()
ViewableData::castingObjectCreatorPair()
ViewableData::CSSClasses()
ViewableData::CurrentMember()
ViewableData::CurrentPage()
ViewableData::customise()
ViewableData::Debug()
ViewableData::defineMethods()
ViewableData::escapeTypeForField()
ViewableData::Even()
ViewableData::EvenOdd()
ViewableData::First()
ViewableData::FirstLast()
ViewableData::getField()
ViewableData::getIterator()
ViewableData::getXMLValues()
ViewableData::hasField()
ViewableData::HasPerm()
ViewableData::hasValue()
ViewableData::i18nLocale()
ViewableData::IsAjax()
ViewableData::iteratorProperties()
ViewableData::JS_val()
ViewableData::Last()
ViewableData::Me()
ViewableData::Middle()
ViewableData::MiddleString()
ViewableData::obj()
ViewableData::Odd()
ViewableData::Pos()
ViewableData::RAW_val()
ViewableData::renderWith()
ViewableData::SecurityID()
ViewableData::setCustomisedObj()
ViewableData::setField()
ViewableData::SQL_val()
ViewableData::ThemeDir()
ViewableData::Top()
ViewableData::TotalItems()
ViewableData::val()
ViewableData::XML_val()
ViewableData::__get()
ViewableData::__isset()
ViewableData::__set()

Inherited From Object

Object::__construct()
Object::addMethodsFrom()
Object::addStaticVars()
Object::addWrapperMethod()
Object::add_extension()
Object::add_static_var()
Object::allMethodNames()
Object::buildMethodList()
Object::cacheToFile()
Object::cacheToFileWithArgs()
Object::clearCache()
Object::combined_static()
Object::create()
Object::createMethod()
Object::defineMethods()
Object::exists()
Object::extend()
Object::extInstance()
Object::getCustomClass()
Object::get_static()
Object::hasExtension()
Object::hasMethod()
Object::has_extension()
Object::invokeWithExtensions()
Object::is_a()
Object::loadCache()
Object::parentClass()
Object::remove_extension()
Object::sanitiseCachename()
Object::saveCache()
Object::set_stat()
Object::set_static()
Object::set_uninherited()
Object::stat()
Object::strong_create()
Object::uninherited()
Object::uninherited_static()
Object::useCustomClass()
Object::__call()
Object::__toString()
blog comments powered by Disqus

Documentation generated on Mon, 23 Mar 2009 06:49:23 +1300 by phpDocumentor 1.3.2