ProcessWire - E-Mail versenden (WireMail): Unterschied zwischen den Versionen
Aus Wikizone
| Zeile 46: | Zeile 46: | ||
<pre> | <pre> | ||
foreach($p->images as $image){ | foreach($p->images as $image){ | ||
| − | $imageSmall = $image->width( | + | $imageSmall = $image->width(640); |
$m->attachment($imageSmall->filename); | $m->attachment($imageSmall->filename); | ||
} | } | ||
</pre> | </pre> | ||
Version vom 13. Februar 2019, 18:39 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 - Felder rendern (renderField)
Attachments aus ProcessWire
foreach($p->images as $image){
$imageSmall = $image->width(640);
$m->attachment($imageSmall->filename);
}