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:
$header = array(
'from' => $senderMail,
'cc' => $theOtherGuy,
'content-type' => 'text/plain; charset=ISO-8859-1'
);
Mailer::mail($recipient, $subject, $text, $header);
// instead of:
$header = "from: $senderMail;\n";
$header .= "cc: $theOtherGuy;\n";
$header .= "content-type: text/plain; charset=ISO-8859-1;\n";
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.
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.
inherited from base classes
Inherited From SmartTemplate
Inherited From Object