Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SMTP PEAR i wysylanie grupowe

2 views
Skip to first unread message

maYk

unread,
Nov 17, 2009, 2:18:55 PM11/17/09
to
Witajcie, mam skrypt ktory grupowo wysyla maile z systemu ktory
stworzylem. Chcialbym jednak do kazdego maila dodac obrazek ktory
sledzilby czy uzytkownik otworzyl maila czy nie. Przy obecnej
konkstrukcji skryptu jest to raczej niemozliwe, bo jak widac ponizej;
najpierw wrzucamy wszystkich odbiorcow do tablicy i potem wysylamy za
jednym zamachem. Kiedy jednak wrzuce ta czesc kodu: $mail = $smtp->send
($recipients, $headers, $message); w petle zmieniajac za kazdym razem
recipients i message to funkcja nie dziala jak powinna i wysyla tylko
jednego maila do pierwszej osoby. Jak to sie robi profesjonalnie?

Dziekuje
Michal

$smtp = Mail::factory('smtp',
array ('host' => $_SESSION['smtp_host'],
'auth' => true,
'username' => $_SESSION['smtp_username'],
'password' => $_SESSION['smtp_password']));
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setHTMLBody($message);
for ($a=0; $a<count($_SESSION['SEND_TO']); $a++){
if ($_SESSION['SEND_TO'][$a]['EMAIL'] != ""){
$recipients[] = $_SESSION['SEND_TO'][$a]['EMAIL'];
$this->save_email_recipient($USTRING, $_SESSION['SEND_TO'][$a]
['GROUP'], $_SESSION['SEND_TO'][$a]['ID']);
}
}
$headers = array ('From' => $_SESSION['first_name'] . " " . $_SESSION
['last_name'] . " <".$_SESSION['email'].">",
'Return-Path' => $_SESSION['email'],
'Subject' => $_POST['subject']);
$message = $mime->get();
$headers = $mime->headers($headers);
$mail = $smtp->send($recipients, $headers, $message);
unset($recipients);
if (PEAR::isError($mail)) {
$this->save_email_content($USTRING, $message, $_POST['subject'],
0,$_SESSION['login']);
echo($mail->getMessage());
$main_dialog = array("stat_not.gif","red","SYSTEM ERROR, PLEASE
CONTACT ADMINISTRATOR");
unset($_SESSION['SEND_TO']);
return "FALSE";
} else {
$this->save_email_content($USTRING, $message, $_POST['subject'],
1,$_SESSION['login']);
$main_dialog = array("stat_ok.gif","green","EMAIL HAS BEEN SENT
SUCCESSFULLY");
unset($_SESSION['SEND_TO']);
return "TRUE";
}

0 new messages