webCOMAND

mail::mail_object()

Send a simple email followed by an object broken down by field.  Only data type and forward reference fields are included.  File Data and Image Data fields will be attached to the emails as files with a filename based on the field and detected file format.

Embedded objects and back-references are not currently supported.

Prototype

boolean mail(mixed $to, string $subject, string $message, cObject $object, array $options = [])

Parameters

  • to - String containing an email address or comma-separated list of email addresses, or an array of email addresses.  Each email address can be a simple email address or a title and email address in "<Full Name> name@example.com" format.
  • subject - String containing the email subject.  If the subject contains UTF8 or other encoded characters, you must manually encode the subject yourself.  For example, '=?utf-8?B?'.base64_encode('sÜßject').
  • message - HTML formatted message.  For example, '<p>Thank you for your form submission.</p>'.
  • object - Object with the field values to display after the message, based on options below.
  • options - An associate array of key/value pairs recognized by option(), plus the following.
    • exclude - Array of Content Type Field Identifiers to exclude from the object field list.
    • from - Email address to display for the where the email is from as a simple email address or title and email address in "<Full Name> name@example.com" format.
    • format - Only "html" is currently recognized and supported.
    • footer - Additional text, like the message, to display after the object field values.
    • headers - Optional associative array of standard email headers.  Common examples:
      • Content-Type - "text/plain", "text/html", etc.
    • include - Array of Content Type Field Identifiers to include in the object field list.  If not specified, all fields will be included, except for those explicitly excluded with the exclude option.  If specified, no fields will be included unless they are specified in this array.  Fields in this array can still be excluded by the exclude option.
    • log - Optional log to log any errors that occur while trying to send the email.

Return

Returns TRUE if the email was successfully accepted for delivery, otherwise FALSE.

Just because the mail was accepted for delivery does NOT mean it will actually reach the intended destination or recipient Inbox.  It may be silently rejected, quarantined or delivered to a Junk Mail, spam or other folder.

Example

$log = new \io_comand_log\log();
$result = \io_comand_email\mail::mail_object(
    'webmaster@webcomand.com',
    'Submission Received',
    "<p>Thank you for your form submission.</p>",
    $form_object,
    [
        'exclude' => ['Password'],
        'from' => 'no-reply@webcomand.com',
        'format' => 'html',
        'footer' => '<p>Thank you,<br/>The webCOMAND Team</p>',
        'headers' => ['X-Custom-Header' => 'Value'],
        'log' => $log
    ]
);

Related

request::update()