ixMailer - PHP5 Class - Create and send multi-part emails

[english]

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:

 

[deutsch]

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

 

  1. <?php
  2. // the ixMailer folder should be in your includepath or in same directory as this file.
  3. require_once ‘ixMailer/ixMailer.php’;
  4.  
  5. // prepare the following vars with your valid data
  6. $to = [email protected];
  7. $fromName = ‘foo bar’;
  8. $fromEmail = [email protected];
  9. $subject = ‘Mail sent with ixMailer’;
  10. $html = <<<html
  11. <h1>This is a headline</h1>
  12. <p>This is a paragraph</p>
  13. <ul>
  14.   <li>This is a list item</li>
  15.   <li>This is another list item</li>
  16. </ul>
  17. <ul><li>Even this list</li><li>is displayed nicely</li><li>in plain text view</li><ul>
  18. html;
  19.  
  20. $text = <<<text
  21. Sorry, but you cant see the html formatting without using HTML display for this email.
  22. The email is a demonstration of the HTML-Email feature of the ixMailer class.
  23. Since you dont display this email as HTML, you cant see the html formatting and
  24. your email reader only shows this text message.
  25. text;
  26.  
  27. // Example 1
  28. // Creating an ixMailer object and set the most important props
  29. $mailer = new ixMailer($to, $fromName, $fromEmail, $subject, $html);
  30. $mailer->sendmail();
  31.  
  32. // Example 2
  33. // Creating an ixMailer object and set the props after
  34. $mailer = new ixMailer();
  35. $mailer->set(‘to’, $to);
  36. $mailer->set(‘fromName’, $fromName);
  37. $mailer->set(‘fromEmail’, $fromEmail);
  38. $mailer->set(‘subject’, $subject);
  39. $mailer->set(‘html’, $html);
  40. $mailer->sendmail();
  41.  
  42. // Example 3
  43. // Creating an ixMailer object and set the props using a function chain
  44. $mailer = new ixMAiler();
  45. $mailer->set(‘to’, $to)
  46.     ->set(‘fromName’, $fromName)
  47.     ->set(‘fromEmail’, $fromEmail)
  48.     ->set(‘subject’, $subject)
  49.     ->set(‘html’, $html)
  50.     ->sendmail();
  51.  
  52. // Example 4
  53. // Creating an ixMAiler object and set the props using an array with setState()
  54. // Adding an alternative text/plain message
  55. $mailer = new ixMailer();
  56. $mailer->setState(array(
  57.         ‘to’ => $to,
  58.         ‘fromName’ => $fromName,
  59.         ‘fromEmail’ => $fromEmail,
  60.         ‘subject’ => $subject,
  61.         ‘html’ => $html,
  62.         ‘text’ => $text
  63.     ))
  64.     ->sendmail();
  65.  
  66. // Example 5
  67. // Creating an ixMailer object and set the props using an array with setState()
  68. // Create the array with compact()
  69. $mailer = new ixMailer();
  70. $mailer->setState(compact(
  71.         ‘to’,
  72.         ‘fromName’,
  73.         ‘fromEmail’,
  74.         ‘subject’,
  75.         ‘html’,
  76.         ‘text’
  77.     ))
  78.     ->sendmail();
  79.  
  80. // Example 6
  81. // Create … and attach a file
  82. $mailer = new ixMailer();
  83. $mailer->setState(compact(
  84.         ‘to’,
  85.         ‘fromName’,
  86.         ‘fromEmail’,
  87.         ‘subject’,
  88.         ‘html’,
  89.         ‘text’
  90.     ))
  91.     ->addAttachment(‘/path/to/a/file’)
  92.     ->sendmail();
  93.  
  94. // Example 7
  95. // Create … and attach some files using set()
  96. $mailer = new ixMailer();
  97. $mailer->setState(compact(
  98.         ‘to’,
  99.         ‘fromName’,
  100.         ‘fromEmail’,
  101.         ‘subject’,
  102.         ‘html’,
  103.         ‘text’
  104.     ))
  105.     ->set(‘attachments’, array(
  106.         ‘/path/to/file’,
  107.         ‘/path/to/file2′,
  108.     ))
  109.     ->sendmail();
  110.  

(ix)

Autor: Ixiter

Kurzlink: http://goo.gl/IyYZf
This entry was posted in ixCodes and tagged , , , , , , , by Ixiter. Bookmark the permalink.

About Ixiter

Ixiter ist Quelltextschreiber, Pixelsortierer, Lieferantenbetreuer und Aufstrichberater. Wenn ihm das alles nicht reicht, schreibt er hier über nichts geringeres, als den Sinn und Unsinn der Existenz. Und wenn ihm die Argumente ausgehen, kommt er mit triftigen Gründen. Immer.

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>