ProcessWire - E-Mail versenden (WireMail): Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „Mit der WireMail Klasse kann man in ProcessWire Mails versenden. https://processwire.com/api/ref/wire-mail/ Beispiel <syntaxhighlight lang="php"> $m = $mail-…“)
 
Zeile 37: Zeile 37:
 
$numSent = $m->send();
 
$numSent = $m->send();
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
Manchmal kann es für E-Mails sinnvoll sein render Templates für einzelne Felder zu haben. Das geht mit der
 +
renderField Funktion.
 +
 +
[[ProcessWire - einzelne Felder rendern (renderField)]]

Version vom 13. Februar 2019, 16:56 Uhr

Mit der WireMail Klasse kann man in ProcessWire Mails versenden.

https://processwire.com/api/ref/wire-mail/

Beispiel

$m = $mail->new(); // option A (prefered)
$m = wireMail(); // option B (prefered)
$m = new WireMail(); // option C (not prefered)

// chained (fluent) method call usage
$m->to('user@domain.com')
  ->from('you@company.com')
  ->subject('Message Subject')
  ->body('Message Body')
  ->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->bodyHTML('<html><body><h1>Message Body</h1></body></html>');
$m->attachment('/path/to/file.ext');
$m->fromName('Mary Jane');
$m->toName('John Smith');
$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();

Manchmal kann es für E-Mails sinnvoll sein render Templates für einzelne Felder zu haben. Das geht mit der renderField Funktion.

ProcessWire - einzelne Felder rendern (renderField)