PHP Classes

File: examples.php

Recommend this page to a friend!
  Classes of Piotr   Lib Mail   examples.php   Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: Example usage of the class
Class: Lib Mail
Compose and send HTML and text e-mail messages
Author: By
Last change:
Date: 11 years ago
Size: 2,359 bytes
 

Contents

Class file image Download
<?php
/*
 * Sending text e-mail
 */
$text = new lib_mail;

//add sender's data
$text->sender('me@mydomains.com', 'My name is');

//who should get the message
$text->addTo('example@example.com');

//subject
$text->subject('test lib_mail');

//text body.
//the "true" parameters tells class to append text to the message body
$text->text('===================='."\n", true);
$text->text('= just = like a ='."\n", true);
$text->text('= text = based ='."\n", true);
$text->text('= table = rows ='."\n", true);
$text->text('===================='."\n", true);

//finally send the message
$text->send();


/*
 * Sending html e-mail with CC and BCC
 */
$html = new lib_mail;

//add sender's data
$html->sender('me@mydomains.com', 'My name is');

//who should get the message
$html->addTo('example@example.com');

//coppies
$html->addCc('mail@domain.com', 'Display name');
$html->addCc('cc@domain.com');

//blind
$html->addBcc('bcc@domain.com', 'Hidden copy name');

//subject
$html->subject('test html lib_mail');

//html body.
//the "true" parameters tells class to append text to the message body
$html->html('<table border="1">', true);
$html->html('<tr><td>just</td><td>a</td></tr>', true);
$html->html('<tr><td>html</td><td>based</td></tr>', true);
$html->html('<tr><td>table</td><td>rows</td></tr>', true);
$html->html('</table>', true);

//send
$html->send();


/*
 * Sending text+html e-mail
 */
$ht = new lib_mail;

//add sender's data
$ht->sender('me@mydomains.com', 'My name is');

//who should get the message
$ht->addTo('example@example.com');

//subject
$ht->subject('test text+html lib_mail');

//text body.
//the "true" parameters tells class to append text to the message body
$ht->text('===================='."\n", true);
$ht->text('= just = like a ='."\n", true);
$ht->text('= text = based ='."\n", true);
$ht->text('= table = rows ='."\n", true);
$ht->text('===================='."\n", true);

//html body.
//the "true" parameters tells class to append text to the message body
$ht->html('<table border="1">', true);
$ht->html('<tr><td>just</td><td>a</td></tr>', true);
$ht->html('<tr><td>html</td><td>based</td></tr>', true);
$ht->html('<tr><td>table</td><td>rows</td></tr>', true);
$ht->html('</table>', true);

//send
$ht->send();