Ver Mensaje Individual
  #4 (permalink)  
Antiguo 30/04/2010, 05:56
Avatar de carscx
carscx
 
Fecha de Ingreso: noviembre-2008
Mensajes: 227
Antigüedad: 15 años, 5 meses
Puntos: 10
Respuesta: Email masivo y adjuntos con PHPMailer

Este el codigo original, el cual envia emails (boletines) a los grupos de usuarios, pero cuando le he querido meter la clase phpmailer y poder adjuntar archivos, no funciona. por si os sirve de ayuda.
Código PHP:
<?php
session_start
();
include 
"connect.php";
include 
"../head.php";
?>
<script language="JavaScript" type="text/javascript" src="wysiwyg.js"></script> 
<center><table border='0'><tr><td valign='top' width=30%>
<?php
if(isset($_SESSION['mailadmin']))
{
   include 
"left.php";
   echo 
"</td>";
   echo 
"<td valign='top' width=70%>";
   echo 
"<table class='maintable'><tr class='headline'><td><center>Send Newsletter</center></td></tr>";
   echo 
"<tr class='mainrow'><td>";
   if(isset(
$_POST['submit']))
   {
      
$nletter=$_POST['nletter'];
      
$subject=$_POST['subject'];
      
$nletter=stripslashes($nletter);
      
$subject=stripslashes($subject);
      
$lists=$_POST['lists'];
      
$nletter=str_replace("rn","<br>",$nletter);
      if(
$lists==0)
      {
        
$selectmails="SELECT * from m_list where validated='1' and mailed='0'";
      }
      else
      {
        
$selectmails="SELECT * from m_list where validated='1' and mailed='0' and listid='$lists'";
       }
      
$selectmails2=mysql_query($selectmails) or die("Could not select mails");
      while(
$selectmails3=mysql_fetch_array($selectmails2))
      {
         
$headers "From: $yourmail \r\n"
         
$headers.= "Content-Type: text/html; charset=ISO-8859-1 "
         
$headers .= "MIME-Version: 1.0 ";
         
mail("$selectmails3[address]","$subject","$nletter<br><br><br>)",$headers);
         
$setassend="update m_list set mailed='1' where mailid='$selectmails3[mailid]'";
         
mysql_query($setassend) or die("COuld not set as send");
      }
      echo 
"Newsletter Sent";
   }
   else
   {
      echo 
"<form action='sendletter.php' method='post'>";
      echo 
"Asunto:<br>";
      echo 
"<input type='text' name='subject' size='20'><br>";
      echo 
"Archivo:<br>";
      echo 
"<input type='file' name='file'><br>";
      echo 
"List to send to:<br>";
      echo 
"<select name='lists'>";
      
$getlists="SELECT * from m_newsletters";
      
$getlists2=mysql_query($getlists) or die("Could not get lists");
      echo 
"<option value='0'>All</option>";
      while(
$getlists3=mysql_fetch_array($getlists2))
      {
         echo 
"<option value='$getlists3[newsletterid]'>$getlists3[newslettername]</option>";
      }
      echo 
"</select><br>";  
      echo 
"Letter to send:<br>";
      echo 
"<textarea name='nletter' rows='8' cols='60' id='7'></textarea><br>";
      echo 
'<script language="JavaScript">';
      echo 
"generate_wysiwyg('7')";
      echo 
"</script>";
      echo 
"<input type='submit' name='submit' value='submit'></form>";

   }
   echo 
"</td></tr></table>";
}
?>
__________________
Frontend Developer
JS+HTML5+CSS3
Backend Developer
PHP+MySQL