|
|
|
|
|
|
| |
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)
?> | | |
|
| Password reminder Categories : PHP, PHP Classes, Databases, MySQL, Mail | | | XPertMailer - Sends TRUE Mails Categories : PHP, Mail, SMTP, PHP Classes | | | Simple Maiing list with newsletter support Categories : PHP, PHP Classes, Mail | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | News management class Categories : PHP, PHP Classes, Beginner Guides | | | The class to check load time of your script
VERY usefull for relatively slow applications, but not only.. Categories : PHP, PHP Classes, Debugging | | | Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself. Categories : PHP, PHP Classes, Templates, Complete Programs | | | Simple Template Class/Example Categories : PHP, Templates, PHP Classes | | | Using this script anyone can easily get a form result to his/her mailbox. You can use this script for any form 2 mail purpose. Categories : PHP, Mail, Form Processing | | | RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | MS Word Mail Merge Automation (COM) Categories : PHP, PHP Classes, COM | | | Very minimal templating engine Categories : PHP, PHP Classes, Templates | | | Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags. Categories : PHP, PHP Classes, Algorithms, Security | |
|
|
|