<!-- inici header --> <!DOCTYPE html> <html lang="ca"> <head> <title>ENVIAR EMAILS CONSULTANT BASE DE DADES</title> <link rel="stylesheet" href="estil.css"> <meta http-equiv="Content-type" content="text/html;charset=utf-8" /> <meta charset="UTF-8"> <meta name="keywords" content="EMAIL"> <meta name="description" content="ENVIAR EMAILS CONSULTANT BASE DE DADES"> <meta name="author" content="webolot.com"> </head> <body> <div class="contenidor"> <?php $host = 'BDD_HOST'; $user = 'BDD_USER'; $password = 'BDD_PASS'; $db = 'BDD'; $link = mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); mysql_set_charset("utf8"); $from="NOM <email@domini.tld>"; $retorn="email@domini.tld"; ?> <!-- fi header --> <!-- inici contingut --> <div class="contingut"> Hem enviat un correu a... <?php $assumpte = $_POST['assumpte']; $titol1 = $_POST['titol1']; $titol2 = $_POST['titol2']; $missatge = $_POST['missatge']; $missatge = nl2br($missatge); $footer = $_POST['footer']; echo "<br/>"; $llistat = mysql_query("SELECT * FROM usuaris WHERE noenviarcorreu = 0 GROUP BY cognoms"); while($resultat = mysql_fetch_array($llistat)) { $correu=$resultat['email']; echo $correu; echo "<br/>"; $msg = " <html lang='ca'> <head> <meta http-equiv='Content-type' content='text/html;charset=UTF-8' /> <meta charset='UTF-8'> </head> <body> <div style='width: 800px;margin-left:auto;margin-right:auto;'> <p style='width:100%;text-align:center;font-size:18px;font-family:verdana;margin:10px;'>".$titol1."</p> <p style='width:100%;text-align:center;font-size:16px;font-family:verdana;margin:10px;'>".$titol2."</p> <p style='width:100%;font-size:12px;font-family:verdana;margin:10px;white-space:pre-wrap;'>".$missatge."</p> <p style='width:100%;background-color:#dddddd;text-align:center;font-size:10px;font-family:verdana;margin:10px;'>".$footer."<br/>LINIA FOOTER 1<br/>LINIA FOOTER 2<br/>LINIA FOOTER 3</p> </div> </body> </html> "; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-Type:text/html;charset=utf-8" . "\r\n"; $headers .= "From: $from\r\nReply-to: $from\r\nReturn-Path: $retorn\r\n"; mail($correu,$assumpte,$msg,$headers,"-femail@domini.tld"); } ?> <div> <!-- fi contingut --> <!-- inici footer --> <?php mysql_close($link); ?> </div> </body> </html> <!-- fi footer -->