WireMail class
A module type that handles sending of email in ProcessWire
Below are 2 different ways you can get a new instance of Wire Once you have an instance of Wire There are 1 Wire Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Set the email message body (text only) Set the email message body (HTML only) Set the email 'from' address and optionally name Set the 'from' name Get property Set multiple email headers using associative array Set the 'reply-to' email address and optionally name (where supported) Set the 'reply-to' name (where supported) Send the email Set property Set the email subject Set the email to address Set the 'to' name Add a file to be attached to the email Encode a subject, use mbstring if available Set any email header Set any email param Return the text quoted-printable encoded In addition to the methods and properties above, Wire$m = $mail->new(); // option A: use $mail API variable
$m = wireMail(); // option B: use wireMail() function$m), you can use it to send email like in these examples below. // chained (fluent) method call usage
$m->to('user@domain.com')
->from('you@company.com')
->subject('Message Subject')
->body('Optional message body in plain text')
->bodyHTML('<html><body><p>Optional message body in HTML</p></body></html>')
->send();
// separate method call usage
$m->to('user@domain.com'); // specify CSV string or array for multiple addresses
$m->from('you@company.com');
$m->subject('Message Subject');
$m->body('Message Body');
$m->send();
// optionally specify “from” or “to” names as 2nd argument
$m->to('user@domain.com', 'John Smith');
$m->from('you@company.com', 'Mary Jane');
// other methods or properties you might set (or get)
$m->fromName('Mary Jane');
$m->toName('John Smith');
$m->replyTo('somebody@somewhere.com');
$m->replyToName('Joe Somebody');
$m->attachment('/path/to/file.ext');
$m->header('X-Mailer', 'ProcessWire');
$m->param('-f you@company.com'); // PHP mail() param (envelope from example)
// note that the send() function always returns the quantity of messages sent
$numSent = $m->send();Wire class also inherits all the methods and properties of: WireData and Wire.Common
Name Return Summary $this
Can also be used as property: $m->body $this
Can also be used as property: $m->bodyHTML $this
Can also be used as property: $m->from $this
Can also be used as property: $m->fromName mixed null $this
Can also be used as property: $m->headers $this
Can also be used as property: $m->replyTo $this
Can also be used as property: $m->replyToName intthis WireData $this
Can also be used as property: $m->subject $this
Can also be used as property: $m->to $this
Can also be used as property: $m->toName Advanced
Name Return Summary $this $m->attachments array Array of file attachments (if populated and where supported) string $this
Can also be used as property: $m->header $m->newline string Newline character, populated only if different from CRLF. $this
Can also be used as property: $m->param string Additional methods and properties
Core Wire
API reference based on ProcessWire core version 3.0.252