|
|
Description
Function runner_mail is PHPRunner wrapper for
mail() function.
Syntax
runner_mail($params)
Arguments
$params - array with input parameters.
The following parameters are supported:
|
·
|
from - sender email
address. If none specified an email address from the wizard will be
used. |
|
·
|
to - receiver email
address. |
|
·
|
cc - email addresses
of secondary recipients. |
|
·
|
bcc - email addresses
of recipients whose addresses are not to be revealed to other
recipients of the message. |
|
·
|
replyTo - reply email
address. |
|
·
|
priority - message
priority (use '1' for urgent, '2' - high, '3' - normal). |
|
·
|
body - plain text
message body. |
|
·
|
htmlbody - html
message body (do not use 'body' parameter in this case). |
|
·
|
charset - html message
charset. If none specified the default website charset will be
used. |
Return value
mailed: (true or false) indicates
whether email was sent or not.
errors: array with list of errors.
Each error is an array with
the following keys:
|
·
|
description: Error description. |
|
·
|
file: Name of the php file in which error happened. |
|
·
|
line: Line number on which error happened |
Example
Send simple email:
|
$email="test@test.com";
$message="Hello there\nBest regards";
$subject="Sample subject";
runner_mail(array('to' => $email, 'subject' => $subject,
'body' => $message));
|
Send HTML email:
|
$email="test@test.com";
$message="Hello there\n<b>Best regards</b>";
$subject="Sample subject";
runner_mail(array('to' => $email, 'subject' => $subject,
'htmlbody' => $message, 'charset' => 'UTF-8'));
|
Example with error
handling:
|
$email="test@test.com";
$subject="Sample subject";
$body="test";
$arr = runner_mail(array('to' => $email, 'subject' => $subject,
'body' => $body));
// if error happened print a message on the web page
if (!$arr["mailed"])
{
echo "Error happened: <br>";
echo "File: " . $arr["errors"][0]["file"] . "<br>";
echo "Line: " . $arr["errors"][0]["line"] . "<br>";
echo "Description: " . $arr["errors"][0]["description"] . "<br>";
}
|
Send email with BCC and CC
fields:
|
$email="test@test.com";
$message="Hello there\nBest regards";
$subject="Sample subject";
runner_mail(array('to' =>
$email, 'cc' => 'test2@test.com',
'bcc' => 'test3@test.com', 'subject'
=>
$subject, 'body' => $message));
|
Send email to multiple
recipients:
|
$email="test@test.com,test2@test.com,test3@test.com";
$message="Hello there\nBest regards";
$subject="Sample subject";
runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $message));
|
|