ProcessWire - E-Mail versenden (WireMail)
Aus Wikizone
Version vom 5. Februar 2021, 19:11 Uhr von 84.136.109.36 (Diskussion)
Mit der WireMail Klasse kann man in ProcessWire Mails versenden. Sie wurde 2014 eingeführt und soll es ermöglichen Module zu entwickeln um den Mailversand z.B. über smtp zu realisieren.
https://processwire.com/talk/topic/5693-new-module-type-wiremail/ https://processwire.com/talk/topic/21070-how-to-sendmail-setup-with-smtpgmail-for-local-web-development/ Ghetto Mailer ProcessWire - WireMailSmtp (Module)
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[Bearbeiten]
foreach($p->images as $image){
$imageSmall = $image->width(640);
$m->attachment($imageSmall->filename);
}
Versand über SMTP[Bearbeiten]
http://modules.processwire.com/modules/wire-mail-smtp/
Kann von anderen Modulen z.B. FormbuilderPro genutzt werden. Kann aber auch genutzt werden um Massenmails zu versenden etc.