ixMailer ist eine PHP5 Klasse zum Erzeugen und Versenden von multi-part Emails. Es wird immer eine HTML- und Textversion der Email integriert und man kann beliebig viele Dateien anhängen.
Der Einsatz der Klasse ist denkbar einfach und durch die Unterstützung von Funktionsketten kann man schönen kompakten Code schreiben.
Die Klasse verwendet keine eigene Fehlerbehandlung. Alle Werte müssen vorher überprüft werden und nur gültige Werte dürfen verwendet werden.
Links:
ixMailer is a PHP5 class to create and send multi-part emails. It will always create an email including HTML- and textversion of the email and you can attach any count of files.
Usage is really simple and by supporting of function chains, you can write pretty an compact codes.
The class doesn’t use an own error handling. All values need to be checked before and only valid values might be used.
Links:
Beispiele - Examples
-
<?php
-
// the ixMailer folder should be in your includepath or in same directory as this file.
-
require_once ‘ixMailer/ixMailer.php’;
-
-
// prepare the following vars with your valid data
-
$fromName = ‘foo bar’;
-
$subject = ‘Mail sent with ixMailer’;
-
$html = <<<html
-
<h1>This is a headline</h1>
-
<p>This is a paragraph</p>
-
<ul>
-
<li>This is a list item</li>
-
<li>This is another list item</li>
-
</ul>
-
<ul><li>Even this list</li><li>is displayed nicely</li><li>in plain text view</li><ul>
-
html;
-
-
$text = <<<text
-
Sorry, but you cant see the html formatting without using HTML display for this email.
-
The email is a demonstration of the HTML-Email feature of the ixMailer class.
-
Since you dont display this email as HTML, you cant see the html formatting and
-
your email reader only shows this text message.
-
text;
-
-
// Example 1
-
// Creating an ixMailer object and set the most important props
-
$mailer = new ixMailer($to, $fromName, $fromEmail, $subject, $html);
-
$mailer->sendmail();
-
-
// Example 2
-
// Creating an ixMailer object and set the props after
-
$mailer = new ixMailer();
-
$mailer->set(‘to’, $to);
-
$mailer->set(‘fromName’, $fromName);
-
$mailer->set(‘fromEmail’, $fromEmail);
-
$mailer->set(‘subject’, $subject);
-
$mailer->set(‘html’, $html);
-
$mailer->sendmail();
-
-
// Example 3
-
// Creating an ixMailer object and set the props using a function chain
-
$mailer = new ixMAiler();
-
$mailer->set(‘to’, $to)
-
->set(‘fromName’, $fromName)
-
->set(‘fromEmail’, $fromEmail)
-
->set(‘subject’, $subject)
-
->set(‘html’, $html)
-
->sendmail();
-
-
// Example 4
-
// Creating an ixMAiler object and set the props using an array with setState()
-
// Adding an alternative text/plain message
-
$mailer = new ixMailer();
-
$mailer->setState(array(
-
‘to’ => $to,
-
‘fromName’ => $fromName,
-
‘fromEmail’ => $fromEmail,
-
‘subject’ => $subject,
-
‘html’ => $html,
-
‘text’ => $text
-
))
-
->sendmail();
-
-
// Example 5
-
// Creating an ixMailer object and set the props using an array with setState()
-
// Create the array with compact()
-
$mailer = new ixMailer();
-
$mailer->setState(compact(
-
‘to’,
-
‘fromName’,
-
‘fromEmail’,
-
‘subject’,
-
‘html’,
-
‘text’
-
))
-
->sendmail();
-
-
// Example 6
-
// Create … and attach a file
-
$mailer = new ixMailer();
-
$mailer->setState(compact(
-
‘to’,
-
‘fromName’,
-
‘fromEmail’,
-
‘subject’,
-
‘html’,
-
‘text’
-
))
-
->addAttachment(‘/path/to/a/file’)
-
->sendmail();
-
-
// Example 7
-
// Create … and attach some files using set()
-
$mailer = new ixMailer();
-
$mailer->setState(compact(
-
‘to’,
-
‘fromName’,
-
‘fromEmail’,
-
‘subject’,
-
‘html’,
-
‘text’
-
))
-
->set(‘attachments’, array(
-
‘/path/to/file’,
-
‘/path/to/file2′,
-
))
-
->sendmail();
-
(ix)
Autor: Ixiter
Kurzlink: http://goo.gl/IyYZf