WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
Web Development Resources
Web Development Content
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
Mobile Dev World

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 : 9856
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 
 


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
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
Render TTF Text to PNG. Text message, font, size, rotation, padding, color, background, and transparency can all be defined via URL.
Categories : PHP, PHP Classes, Graphics
PHP Zip Utility
Categories : PHP, PHP Classes, Compression
Convert text to 'quoted printable' without the IMAP package installed.
Categories : PHP, Mail, IMAP
simple shopping cart for php3
Categories : PHP, PHP Classes, Complete Programs, Ecommerce
Online Automatic Class Generator for MySQL Tables
Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL
Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item.
Categories : PHP Classes, PHP, Java Script, DHTML
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Excel class in PHP
Categories : PHP, PHP Classes, Excel
Data Retrieve from mailbox and generate the SQL Syntax
Categories : PHP, IMAP, Mail
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
Protect your email links from being spidered by spam email robots!
Categories : PHP, Security, Mail, Email