WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Email Class
Categories : PHP, Mail, PHP Classes Update Picture
JJ Harrison
Date : Aug 23rd 2003
Grade : 3 of 5 (graded 11 times)
Viewed : 11010
File : No file for this code example.
Images : No Images for this code example.
Search : More code by JJ Harrison
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 


Mailer class by JJ Harrison, example at bottom

<?php
class mailer

   var
$headers;      // An array of headers
   
var $recipients;   // An array of recipients
     
var $subject;      // The message subject
     
var $message;      // The message body
     
function from($name, $email)
     {   
// Sets who the email was from
         
@ini_set('sendmail_from','newsletters@tececo.com');
         
$this->headers[] = 'From: '.$email.' <'.$name.'>';
     }
     
   function
add_recipient($email)
     { 
// Adds a recipient in the to: field
       
$this->recipients[] = $email;
     }
     
     function
add_cc($email)
     { 
//Adds a carbon copy address
       
$this->headers[] = 'CC: '.$email;
     }
     
     function
add_bcc($email)
     { 
//Adds a blind carbon copy address
       
$this->headers[] = 'BCC: '.$email;
     }
     
     
     function
subject($subject)
     { 
//Sets the message subject
       
$this->subject = $subject;
     }
     
     function
message($message)
     { 
//Sets the message body
       
$this->message = $message;
     }
     
     function
custom_header($headername, $headervalue)
     { 
//Adds a custom header
           
$this->headers[] = $headername.': '.$headervalue;
     }
     
     function
send()
     { 
//sends the email
     
$recipients_separated = implode(",", $this->recipients);
       
$headers = "";
            foreach(
$this->headers as $header)
            {
               
$header .= $headers."\r\n";
            }
           
mail($recipients_separated, $this->subject, $this->message, $headers);
     }
};

Usage Example:

$mailout = new mailer;
$mailout->from('sender@example.com', 'Sender');
$mailout->add_recipient('person1@example.com');//add a recipient in the to: field
$mailout->add_cc('person2@example.com');//carbon copy
$mailout->add_bcc('person3@example.com');//blind carbon copy
$mailout->subject('Test');//set subject
$mailout->message('Hi,

FILLER
---------------------------------------------
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
---------------------------------------------

Thank You!
'
);//set message body
$mailout->send();//send email(s)
?>



XPertMailer - Sends TRUE Mails
Categories : PHP, Mail, SMTP, PHP Classes
Simple Maiing list with newsletter support
Categories : PHP, PHP Classes, Mail
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
Very minimal templating engine
Categories : PHP, PHP Classes, Templates
Request Method Class - seful for situations like form processing or API development. Requires PHP5 for the magic __call() method.
Categories : PHP, PHP Classes, HTTP, Headers
base64 with encryption - encode and decode sessions
Categories : PHP, PHP Classes, Encryption, Sessions
PDF class - This is a useful class to make a pdf file with php functions.
Categories : PHP, PDF, PHP Classes
Use of bitmasks to represent permissions
Categories : PHP, Authentication, Bitwise Operators, Security, PHP Classes
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
Gonx Proxy - This class is meant to act as an HTTP proxy to serve pages of a remote server as if they were local pages.
Categories : PHP, PHP Classes, HTTP
MS Word Mail Merge Automation (COM)
Categories : PHP, PHP Classes, COM
php for odbc /* connect to access from odbc */
Categories : PHP Classes, ODBC, MS Access, PHP
A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP
XML easy parser
Categories : PHP, XML, PHP Classes
My Box - PHP Class that calculates the volumetric weight of a package.
Categories : PHP, Object Oriented, PHP Classes, Beginner Guides, Payment Gateways