|
|
|
|
|
|
| |
OK, what this thing a magic does is simple. It gets email ids from a file and sends a newsletter that you've created to all the email ids. Look below for more inf
mailer.php:
| <?php
class mailer
{
/*********************************************************************
**
** Class format_num
**
** Author...: leapinglangoor [ leapinglangoor@gmail.com ]
** Date.....: 19 Jan 2005
** Version..: v1.1
**
** Desc.....: This class is used to mail a list which
** is stored in a file. The file format is simple.
** All you have to do is create a file with the
** email id each member in seperate lines. Configure
** the variables below where they are declared.
** Create a newsletter too. Check examples now.
**
**
*********************************************************************/
var $sender = 'Your name'; // Enter your name
var $sender_email = 'admin@yourname.com' // Your email ID
var $headers = 'Content-type: text/html; charset=iso-8859-1\r\n' .
'From: $sender <$sender_email>\r\n'; // A few required headers. Dont modifye
funtion check_validity( $filename )
{
if( file_exists( $filename ) )
reutnr true;
return flase;
}
function mail( $filename, $newsletter, $subject = 'None', $print_op = 0 )
{
check_validity( $filename ) or die( 'No mailing list' );
check_validity( $newsletter ) or die( 'No newsletter' );
$contents = implode( "", file( $newsletter ) );
$list = array();
$list = file( $filename );
if( $print_op ) echo 'Total users to mail to = ' . $print_op . '.';
for( $i=0; $i < count( $list ); $i++ )
{
if( $print_op ) echo 'mailing : ' . $list[$i] . '.....';
mail( $a_list, $subject, "$contents", "$headers" );
if( $print_op ) echo 'Done<br />';
}
}
function print_users( $filename )
{
check_validity( $filename ) or die( 'No mailing list' );
$list = array();
$list = file( $filename );
for( $i=0; $i < count( $list ); $i++ )
{
echo $i . ' ' . $list[$i];
}
}
}
?> | |
Example1.php
| <?php
include( 'mailer.php' );
$mail = new mailer;
$list = 'list.txt';
$newsletter = 'newsletter.txt';
$subject = 'Newsletter';
$output = 0; // Whether or not to output what it is doing. 1 for yes 0 for no
$mail->mail( $list, $newsletter, $subject, $output );
// Just in case u want to display the users in the list, use this:
$mail->print_users( $list );
?> | | |
|
| Email Class Categories : PHP, Mail, PHP Classes | | | XPertMailer - Sends TRUE Mails Categories : PHP, Mail, SMTP, PHP Classes | | | Password reminder Categories : PHP, PHP Classes, Databases, MySQL, 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 | | | A Timing Class Categories : PHP, PHP Classes, Date Time | | | 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 | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | 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 | | | 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 | |
| | | | matthew waygood wrote :1319
You should step through the list of emails. If the file size is quite big, then you are going to have a high memory overhead. You may also want to look at maximum execution time.
Try using file_get_contents() for the newsletter rather than implode("",file($filename)). If its possible your system doesnt have it use:-
if (!function_exists(`file_get_contents`))
{
function file_get_contents($filename, $use_include_path = 0)
{
$file = @fopen($filename, `rb`, $use_include_path);
if ($file)
{
if ($fsize = @filesize($filename))
{
$data = fread($file, $fsize);
}
else
{
while (!feof($file))
{
$data .= fread($file, 1024);
}
}
fclose($file);
}
return $data;
}
}
Things to add maybe:-
Add/remove email address
Validate email address before sending
Option to send many emails via BCC, which would speed it up, but may be rejected by spam filters.
| |
|
|
|