Cytat(netvalue @ 11.04.2009, 11:16:33 )

1. jak będę posiadał 60k maili w bazie czy pliku

... To myślisz że wszystko gładko wyśle za jednym zamachem

?
tak tak już o tym pomyślałem. dodam odpowiednie funkcje.
Cytat(netvalue @ 11.04.2009, 11:16:33 )

2. Może warto byłoby zaopatrzyć maila w nagłówki i autoryzację smtp. przy obecnym stanie większość serwerów oznaczy to flagą SPAM

nagłóweczki już są choć narazie chce zrobić ogólny zarys klasy i zapytać innych o zdanie.
Cytat(skowron-line @ 11.04.2009, 12:32:16 )

@piotrooo89 a dlaczego wymyślasz koło od nowa jest klasa phpMailer ma wszystko czego tobie potrzeba.
tak jak napisał ~
phpion:
Cytat(phpion @ 11.04.2009, 12:42:36 )

Może dlatego, że się chłopak uczy?
i chyba bardziej cieszy coś własnego

a wracając do tematu jak oceniacie? co zmienić, dodać?
aktualnie wygląda to tak:
newsletter.Class.php<?php
abstract class Loader
{
abstract public function load();
public $errors =
'no_file' => 'Plik nie istnieje',
'wrong_separator' => 'Nie podano separatora',
'wrong_sql' => 'Brak zapytania SQL',
'wrong_sql_col' => 'Podaj kolumne z adresami e-mail',
'wrong_sql_tab' => 'Podaj tabele SQL'
);
}
class Loader_File extends Loader
{
public function __construct($file, $separator)
{
throw new Exception($this->errors['wrong_separator']);
$this->file = $file;
$this->sep = $separator;
}
public function load()
{
throw new Exception($this->errors['no_file']);
$mails_file = explode($this->sep, $string); return $mails_file;
}
}
class Loader_Database extends Loader
{
public function __construct($col, $tab)
{
throw new Exception($this->errors['wrong_sql']);
throw new Exception($this->errors['wrong_sql_col']);
throw new Exception($this->errors['wrong_sql_tab']);
$this->col = $col;
$this->tab = $tab;
}
public function load()
{
$sql_query = mysql_query("SELECT `".$this->col."` FROM `".$this->tab."`"); {
$mails_db[] = $rows[0];
}
return $mails_db;
}
}
class Newsletter
{
private $loader;
public function setLoader(Loader $loader)
{
$this->loader = $loader;
}
public function getMails()
{
return $this->loader->load();
}
public function Send($where, $subject, $message, $head)
{
foreach($where as $mails)
{
mail($mails, $subject, $message, $head); }
}
}
?>
index.php<?php
require_once ('newsletter.Class.php');
require_once ('mysql.php');
$topic = 'Test';
$msg = 'Wiadomość testowa';
$headers .= "From: Olaszewski <piotroo89@gmail.com>r\n";
$headers .= "Reply-To: Olaszewski <piotroo89@gmail.com>r\n";
$headers .= "Return-Path: Olaszewski <piotroo89@gmail.com>r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() ."r\n"; $headers .= 'MIME-Version: 1.0'. "\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "r\n";
$headers .= "Content-transfer-encoding: utf-8r\n";
$column_sql = 'mail';
$table_sql = 'emails';
$f = 'mail.txt';
try
{
$news = new Newsletter();
$file = new Loader_File($f, ';');
$db = new Loader_Database($column_sql, $table_sql);
$news -> setLoader($db);
$news -> Send($news->getMails(), $topic, $msg, $headers);
}
catch(Exception $e)
{
$error = ($e->getMessage());
}
?>