<?php
#################################################################################
#               Mail function of the newsletter module 
# This function uses the phpmailer class (included in de admin.php, if you want to use a different
# mail method you can replace the newsletter_mail function by your own.
# 
############################################################################
# mail_function2.php: last changed 10/04/2006  , version: 1.0
#                  by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: mail_function2.php,v 1.1 2006/10/03 10:33:56 fstuurman Exp $
############################################################################
if ( !defined('IN_SAS') )
{
	die("Hacking attempt");
}

function newsletter_mail($email_list,$content,$owner_email,$subject) 
{
//the $email_list is an array with all the emails we are going to sent the newsletter
//$email_list = ontains the actual emails as array
//$content =  actual newsletter content, contains the link when send_link = 1
//$owner_email = this is the email address of the of newsletter owner
//$subject = contains the subject for the emails

$content = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
			<html>
			<head>
			<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">
			<title>$newsletter_name</title>
			</head><body>".$content."</body></html>" ;
$content = wordwrap($content) ;

//require("modules/sn_newsletter/class.phpmailer.php");   //use the phpmailer class
$mail = new PHPMailer();
$mail->From = $owner_email;
$mail->FromName = " ";
$mail->Subject = $subject;
$mail->Body = $content;
$mail->IsHTML(true);

$number = count($email_list) ;                          //number of emails to process
$i = 0 ;

	while ($i < $number)
	{
	set_time_limit(30) ;
	$mail->AddAddress($email_list[$i]);
	$mail->Send() ;
	$i++;  
	$mail->ClearAddresses();
	}
return $number;
}
?>