-
Funzione mail
Buona sera
Ho visto che sul tuo sito ci sono un sacco di tutorial – ma non riesco a trovare quello che mi serve
E’ possibile inviare una mail con php è il testo del messaggio deve essere letto dal db??? (ecco esempio che ho fatto ma non funziona nella mail mi arriva il codice)
Codice HTML:
$mittente=$mail;
$destinatario = $mail;
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: $nome $cognome - $mittente<$mittente> \r\n";
//$header .= "Reply-to: [email]collega@mioserver.it[/email]\r\n";
//$reply = "Reply-to: $mittente\r\n";
$oggetto = "Richesta Preventivo";
$query=mysql_query("select * From carrello")or die ("Query non valida:" . mysql_error());
$num1=mysql_num_rows($query);
$messaggio =
"<html>
<body>
<font size='+3' color='#00FF00' face='Times New Roman, Times, serif'><b>
<div align='right'>Salve Serineon<br><br></div></b></font>
<b>Oggetto: Richiesta Preventivo</b><br><br>
$messaggio =
"<html>
<body>
<font size='+3' color='#00FF00' face='Times New Roman, Times, serif'><b>
<div align='right'>Salve Serineon<br><br></div></b></font>
<b>Oggetto: Richiesta Preventivo</b><br><br>
<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"940\" border=\"0\" >
<tr class=\"cella2\">
<td width=\"101\"><strong>Id Prodotto </strong></td>
<td width=\"682\" height=\"30\"><strong>Nome Prodotto </strong></td>
<td width=\"70\"><strong>Q.tà </strong></td>
</tr>
<?php
$tot1=0;
for($i=0;$i<$num1;$i++)
{
$id=mysql_result($query,$i,\"id\");
$id_art=mysql_result($query,$i,\"id_art\");
$id_prod=mysql_result($query,$i,\"id_prod\");
$nome=mysql_result($query,$i,\"nome_prod\");
$prezzo=mysql_result($query,$i,\"prezzo\");
$quantita=mysql_result($query,$i,\"quantita\");
$stampa=mysql_result($query,$i,\"stampa\");
if($stampa!=\"serigrafia\")
{
$stampa=$stampa.\" :Preventivo\";
}
$totale=$prezzo*$quantita;
$iva=$totale*0.2;
$tot=$totale+$iva;
$tot1=$tot1+$tot;
?>
<tr>
<td><?php echo $id_prod; ?></td>
<td><?php echo $nome;?></td>
<td><?php echo $quantita; ?></td>
</tr>
<?php }
//$Prezzo=mysql_query(\"select sum(totale) as Prezzo from carrello where ip='$ip' \");
//$Prezzo1=mysql_result($query,\"totale\")
?>
<tr>
<td colspan=\"3\" align=\"right\"> </td>
</tr>
<tr>
<td colspan=\"3\" align=\"right\" bgcolor=\"#FFFF00\"> </td>
</tr>
</table>
</body>
</html>
";
</body>
</html>";
$destinatario1="gasparroa@tiscali.it";
mail($destinatario, $oggetto, $messaggio, $header);
mail($destinatario1, $oggetto, $messaggio, $header);
echo "<br><br><br>Mail inviata con successo<br><br><br><br>";
-
Certo che puoi! ^^
Codice PHP:
$sql = mysql_query("SELECT testo FROM emails WHERE id = '33'"); // esempio di prelievo dal db del campo testo dalla tabella email alla "linea" 33
$ris = mysql_fetch_array($sql);
$mail = mail("per","ogg",$ris["0"],"");
if($mail) { echo "Ok!"; }
else { echo "ERRORE!"; }
Ciauu! ^^
-
come ho fatto io pero nn funziona mi manda la mail ma con codice dentro
si puo inserire un ciclo che legge + risultati
-
Certo... sostituisci tutti i ' con \"
-
Gia ho sostituito tutti i campi ma non va
:cry:
-
Mmm... prova ora:
Codice PHP:
<?php
$mittente=$mail;
$destinatario = $mail;
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: $nome $cognome - $mittente<$mittente> \r\n";
//$header .= "Reply-to: collega@mioserver.it\r\n";
//$reply = "Reply-to: $mittente\r\n";
$oggetto = "Richesta Preventivo";
$query=mysql_query("select * From carrello")or die ("Query non valida:" . mysql_error());
$num1=mysql_num_rows($query);
$messaggio =
"<html>
<body>
<font size='+3' color='#00FF00' face='Times New Roman, Times, serif'><b>
<div align='right'>Salve Serineon<br><br></div></b></font>
<b>Oggetto: Richiesta Preventivo</b><br><br>
$messaggio =
"<html>
<body>
<font size='+3' color='#00FF00' face='Times New Roman, Times, serif'><b>
<div align='right'>Salve Serineon<br><br></div></b></font>
<b>Oggetto: Richiesta Preventivo</b><br><br>
<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"940\" border=\"0\" >
<tr class=\"cella2\">
<td width=\"101\"><strong>Id Prodotto </strong></td>
<td width=\"682\" height=\"30\"><strong>Nome Prodotto </strong></td>
<td width=\"70\"><strong>Q.tà </strong></td>
</tr>
<?php
$tot1=0;
for($i=0;$i<$num1;$i++)
{
$id=mysql_result($query,$i,\"id\");
$id_art=mysql_result($query,$i,\"id_art\");
$id_prod=mysql_result($query,$i,\"id_prod\");
$nome=mysql_result($query,$i,\"nome_prod\");
$prezzo=mysql_result($query,$i,\"prezzo\");
$quantita=mysql_result($query,$i,\"quantita\");
$stampa=mysql_result($query,$i,\"stampa\");
if($stampa!=\"serigrafia\")
{
$stampa=$stampa.\" :Preventivo\";
}
$totale=$prezzo*$quantita;
$iva=$totale*0.2;
$tot=$totale+$iva;
$tot1=$tot1+$tot;
?>
<tr>
<td><?php echo $id_prod; ?></td>
<td><?php echo $nome;?></td>
<td><?php echo $quantita; ?></td>
</tr>
<?php }
//$Prezzo=mysql_query(\"select sum(totale) as Prezzo from carrello where ip='$ip' \");
//$Prezzo1=mysql_result($query,\"totale\")
?>
<tr>
<td colspan=\"3\" align=\"right\"> </td>
</tr>
<tr>
<td colspan=\"3\" align=\"right\" bgcolor=\"#FFFF00\"> </td>
</tr>
</table>
</body>
</html>
</body>
</html>";
$destinatario1="gasparroa@tiscali.it";
mail($destinatario, $oggetto, $messaggio, $header);
mail($destinatario1, $oggetto, $messaggio, $header);
echo "<br><br><br>Mail inviata con successo<br><br><br><br>";
?>
-
praticamente ho una sorta di carrello in cui sono contenuti degli articoli
dovrei leggere tutti gli articoli del carrello per l' idutente='33'
e inviarli per mail
lo stesso risultato, provero domani meglio a mente fresca
grazie
-
Ecco qui:
Codice PHP:
<?php
$mittente=$mail;
$destinatario = $mail;
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: $nome $cognome - $mittente<$mittente> \r\n";
//$header .= "Reply-to: collega@mioserver.it\r\n";
//$reply = "Reply-to: $mittente\r\n";
$oggetto = "Richesta Preventivo";
$query=mysql_query("select * From carrello")or die ("Query non valida:" . mysql_error());
$num1=mysql_num_rows($query);
$messaggio =
<<<echo
<html>
<body>
<font size="+3" color="#00FF00" face="Times New Roman, Times, serif"><b>
<div align="right">Salve Serineon<br><br></div></b></font>
<b>Oggetto: Richiesta Preventivo</b><br><br>
echo;
$messaggio = <<<echo
<html>
<bod>
<font size="+3" color="#00FF00" face="Times New Roman, Times, serif"><b>
<div align="right">Salve Serineon<br><br></div></b></font>
<b>Oggetto: Richiesta Preventivo</b><br><br>
<table align="center" cellpadding="0" cellspacing="0" width="940" border="0">
<tr class="cella2">
<td width="101"><strong>Id Prodotto </strong></td>
<td width="682" height="30"><strong>Nome Prodotto </strong></td>
<td width="70"><strong>Q.tà </strong></td>
</tr>
echo;
$tot1=0;
for($i=0;$i<$num1;$i++)
{
$id=mysql_result($query,$i,\"id\");
$id_art=mysql_result($query,$i,\"id_art\");
$id_prod=mysql_result($query,$i,\"id_prod\");
$nome=mysql_result($query,$i,\"nome_prod\");
$prezzo=mysql_result($query,$i,\"prezzo\");
$quantita=mysql_result($query,$i,\"quantita\");
$stampa=mysql_result($query,$i,\"stampa\");
if($stampa!=\"serigrafia\")
{
$stampa=$stampa.\" :Preventivo\";
}
$totale=$prezzo*$quantita;
$iva=$totale*0.2;
$tot=$totale+$iva;
$tot1=$tot1+$tot;
?>
<tr>
<td><?php echo $id_prod; ?></td>
<td><?php echo $nome;?></td>
<td><?php echo $quantita; ?></td>
</tr>
<?php }
//$Prezzo=mysql_query(\"select sum(totale) as Prezzo from carrello where ip='$ip' \");
//$Prezzo1=mysql_result($query,\"totale\")
?>
<tr>
<td colspan=\"3\" align=\"right\"> </td>
</tr>
<tr>
<td colspan=\"3\" align=\"right\" bgcolor=\"#FFFF00\"> </td>
</tr>
</table>
</body>
</html>
</body>
</html>";
$destinatario1="gasparroa@tiscali.it";
mail($destinatario, $oggetto, $messaggio, $header);
mail($destinatario1, $oggetto, $messaggio, $header);
echo "<br><br><br>Mail inviata con successo<br><br><br><br>";
?>
Usa questo codice invece di mettere \" quando devi fare lunghe cose!!! XD
Codice PHP:
$var = <<<echo
testo in "html" anche con " ciao " ma senza \" XDDD
echo;
echo $var;