prima di tutto creati il form:
<html>
<head>
<title>Ma mia mini newsletters</title>
</head>
<body>
<form name="send_all_mail" method="post" action="send_all_mail.php">
<table>
<tr>
<td><font face="verdana" size="1" color="black">Titolo:</font></td>
<td><input type="text" name="subject" size="50"></td>
</tr>
<tr>
<td valign="top"><font face="verdana" size="1" color="black">Testo:</font></td>
<td>
<textarea cols="60" rows="10" name="message"
>Scrivi qui il testo</textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Invia">
<input type="reset" value="Cancella">
</td>
</tr>
</table>
</form>
</body>
</html>
dopo di che passi il tutto a: send_all_mail.php
questo e` lo script:
Codice PHP:
<html>
<head>
<title>Invio le e-mail!</title>
</head>
<body>
<?php
require ("connessione.php");
$sql = " SELECT * FROM tabella";
$rs = mysql_db_query( $database, $sql, $db) or die(mysql_error());
$tot_mail = 0;
while ($riga = mysql_fetch_array ($rs))
{
$to = "".$riga["email"]."";
$from = "tuo@indirizzo_email";
$subject = $_POST["subject"];
$message = $_POST["message"];
$headers = "From: " . $from . "\r\n";
mail($to, $subject, $message, $headers);
$tot_mail++;
}
print "E-mail inviate: $tot_mail ";
?>
</body>
</html>
provalo dovrebbe funzionare