Send an email or get a WireMail object to populate before send

  • Please note that the order of arguments is different from PHP’s mail() function.
  • If no arguments are specified it simply returns a WireMail object (see #4 below).
  • This is a procedural version of functions provided by the $mail API variable (see that for more options).
  • This function will attempt to use an installed module that extends WireMail.
  • If no other WireMail module is installed, the default WireMail (which uses PHP mail) will be used instead.

// Default usage:
wireMail($to, $from, $subject, $body, $options);

// Specify body and/or bodyHTML in $options array (perhaps with other options):
$options = [ 'body' => $body, 'bodyHTML' => $bodyHTML ];
wireMail($to, $from, $subject, $options);

// Specify both $body and $bodyHTML as arguments, but no $options:
wireMail($to, $from, $subject, $body, $bodyHTML);

// Specify a blank call to wireMail() to get the WireMail sending object. This can
// be either WireMail() or a class descending from it. If a WireMail descending
// module is installed, it will be returned rather than WireMail():
$mail = wireMail();
$mail->to('user

Usage

// basic usage
$int = wireMail();

// usage with all arguments
$int = wireMail($to = '', string $from = '', string $subject = '', $body = '', $options = array);

Arguments

NameType(s)Description
to (optional)string, array

Email address TO. For multiple, specify CSV string or array.

from (optional)string

Email address FROM. This may be an email address, or a combined name and email address. Example of combined name and email: `Karen Cramer <karen

subject (optional)string

Email subject

body (optional)string, array

Email body or omit to move straight to $options array

options (optional)array, string

Array of options OR the $bodyHTML string. Array $options are:

  • bodyHTML (string): Email body as HTML.
  • body (string): Email body as plain text. This is created automatically if you only provide $bodyHTML.
  • headers (array): Associative array of ['header name' => 'header value']
    • Any additional options you provide will be sent along to the WireMail module or class, in tact.

Return value

int WireMail

Returns number of messages sent or WireMail object if no arguments specified.


Functions methods and properties

API reference based on ProcessWire core version 3.0.137

Twitter updates

  • ProcessWire 3.0.142 has a lot of updates but the biggest is the addition of custom fields support for file and image fields. In this post, we take a closer look at that, and also outline all of the new features in the just-released FormBuilder v40— More
    11 October 2019
  • This week’s dev branch version brings you improvements to ProcessWire’s input->cookie API variable, plus it adds the ability to modify system URLs and paths at runtime. This post also includes some examples to demonstrate just how useful this can be— More
    20 September 2019
  • New post: This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140— More
    6 September 2019

Latest news

  • ProcessWire Weekly #284
    In the 284th issue of ProcessWire Weekly we're going to take a quick look at the latest core updates, introduce a new module called InputfieldFloatRange, and continue our ongoing poll series #processwireworks. Read on!
    Weekly.pw / 20 October 2019
  • ProcessWire 3.0.142 core updates
    This latest version of the core on the dev branch has a lot of updates, and the biggest is the addition of custom fields support for file and image fields. In this post, we take a closer look and also outline all of the new features in the just-released FormBuilder v40.
    Blog / 11 October 2019
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer