webCOMAND

io_comand_email\mail

Send emails, which may include attachments.

In general, anywhere an email address is accepted, it may be specified as a simple email address (name@company.com) or friendly email address (Full Name <name@company.com>).

Properties

The following properties can be read and modified.

  • to - A comma-separated list of email addresses that the email will be sent to.
  • from - The email address that will appear in the from of the sent email.  This will replace a From header if it was also set.  If neither this or the From header are set, the 'default_from' option in config/io_comand_email/mail.php will be used, and if that is not defined, support@webcomand.com will be used.
  • subject - The subject to send with the email.
  • message - The message to send with the email.
  • message_html - The message to send in HTML format.

Plain Text Example

The following example will send a simple plain-text email from the default email address configured on the server.

// Send a simple plaintext email.
$to = 'webmaster@webcomand.com';
$subject = 'Testing';
$message = "This is a test.\nTesting 1, 2, 3.";
\io_comand_email\mail::mail($to, $subject, $message);

HTML Example

The following example will send an HTML email with custom headers and attachments.

// Send an HTML email.
$mail = new \io_comand_email\mail();
$mail->from = 'webCOMAND Webmaster <webmaster@webcomand.com>';
$mail->to = 'webCOMAND Support <support@webcomand.com>';
$mail->subject = 'Testing';
$mail->message = "<p>This is a test.<p>\n<p>Testing 1, 2, 3.</p>\n";
$mail->html(TRUE);
$mail->header('X-Email-Client', 'webCOMAND');
$mail->attach('test.txt', 'This is a text file attachment.');
$mail->send();

HTML & Plaintext Example

The following example will send an HTML email with a plain text alternative.

// Send an HTML email.
$mail = new \io_comand_email\mail();
$mail->from = 'webCOMAND Webmaster <webmaster@webcomand.com>';
$mail->to = 'webCOMAND Support <support@webcomand.com>';
$mail->subject = 'Testing';
$mail->message = "This is a test.\nTesting 1, 2, 3.";
$mail->message_html = "<p>This is a test.<p>\n<p>Testing 1, 2, 3.</p>\n";
$mail->send();