Código PHP:
<?php
include "config.php";
require_once('class.phpmailer.php');
$username = $_COOKIE['loggedin'];
if ($username != "breaker_v"){
echo "No estás autorizado para acceder a esta sección";
}
else {
mysql_connect($server, $db_user, $db_pass) or die (mysql_error());
mysql_select_db($database) or die (mysql_error());
$result = mysql_query("select * from $table order by username asc") or die (mysql_error());
if ($result) {
echo "<font size=3 color=#FFFFFF>Tratando de enviar el mensaje a:<br><br>";
while ($qry = mysql_fetch_array($result)){
$lista_mail[]="$qry[email],"; // array que contiene todos los emails recuperados por tu query
echo "$qry[email]<br>";
}
}
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("[email protected]","Storm of Sighs");
$mail->SetFrom('[email protected]', 'Storm of Sighs');
$mail->AddReplyTo("[email protected]","Storm of Sighs");
$address = implode($lista_mail); // lista de emails separado por comas
$mail->AddAddress($address, "Storm of Sighs");
$mail->Subject = "Webmail de Storm of Sighs!";
$mail->AltBody = "Para ver este mensaje, usa una verión compatible de HTML";
$mail->MsgHTML($body);
$mail->AddAttachment("objetos/firma.jpg"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Mensaje enviado correctamente a $address";
}
}
?>