yana

phpDocumentor v 1.4.0

Class Mailer

Description

create and send mails based on templates
  • access: public
Object
   |
   --SmartTemplate
      |
      --Mailer
Variable Summary
string $sender
string $subject
Method Summary
  • bool mail (string $recipient, string $subject, string $text, [array $header = array()])
  • bool send (string $recipient)

Variables

string $sender = ""
  • access: public
string $subject = ""
  • access: public

Methods

send an e.mail
bool mail (
string $recipient, string $subject, string $text, [array $header = array()]
)
List of parameters:
Name Type Description
$recipient string mail address
$subject string short description
$text string message text
$header array (optional)
Description:
This function sends an e.mail and lets you provide the recipient, subject, text and header.
Note that this method introduces several filters to prevent header-injection attacks, that might be used to send spam mails.
Due to this feature, this method should be prefered over of PHP's native mail() function in any productive environment.
One should note that the 4th parameter, containing the header-information, is an associative array here, rather than a string.
This means, you need to write this parameter as follows:
  1.  $header array(
  2.  'from'         => $senderMail,
  3.  'cc'           => $theOtherGuy,
  4.  'content-type' => 'text/plain; charset=ISO-8859-1'
  5.  );
  6.  Mailer::mail($recipient$subject$text$header);
  7.  // instead of:
  8.  $header "from: $senderMail;\n";
  9.  $header .= "cc: $theOtherGuy;\n";
  10.  $header .= "content-type: text/plain; charset=ISO-8859-1;\n";
  11.  mail($recipient$subject$text$header);
  • Note that for security reasons the $header parameter does not allow recipients to be defined using 'bcc'. You should use 'cc' instead.
  • Also note that the default encoding for mails send via this method is plain text in ISO Latin-1. You may change this via the $header var 'content-type'.
  • When sending HTML-mails the following tags will automatically be removed for security reasons: link, meta, script, style, img, embed, object, param. In addition any '@' sign within the subject or text of the message will be replaced by the phrase "[at]". As this is a blacklist approach, it is not completely failproof. You are encouraged to prepend additional checks as you see fit, before passing your params to this method.
  • When recieving a mail send via this method, you might want to check the mail's header for two flags named 'x-yana-php-header-protection' and 'x-yana-php-spam-protection'. The first indicates the result of the header-injection checks. It's value should be '0'. If the value is '1', than some filter did note some suspicious header data and dropped it, before sending the mail. This might be the result of an header-injection attack. The number is followed by a white-space and a description in round brackets, e.g. "0 (no suspicious header found)". The second indicates the result of the spam-protection checks. You may preset both values if you want to run your own filters before passing values to this method. In addition you might want to tell your local spam-filter to sort out any messages, that have these parameters set to '1'.
See the developer's cookbook for more detailed information and examples.
  • since: 2.8
  • access: public
  • uses: Mailer::mail('recipient@somewhere.tld', - 'My Subject', 'My Text', array('from' => 'myMail@domain.tld'));
send an e.mail
bool send (
string $recipient
)
List of parameters:
Name Type Description
$recipient string mail address
Description:
This function sends an e.mail with the currently set subject and content to the recipient you provide.
  • since: 2.8
  • access: public
  • uses: $mailer->send('recipient@somewhere.tld');
inherited from base classes

Inherited From SmartTemplate

Inherited From Object

Documentation generated on Sat, 03 Jan 2009 22:22:30 +0100 by phpDocumentor 1.4.0

yana author: Thomas MeyerHomepage: www.yanaframework.net