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