Entra

View Full Version : [php] Form mail con immagine


lemix07
25-11-2009, 09:09
vorrei inviare dal mio sito delle email con delle immagini , che aprendo le email dal client le immagini si vedano ho creato questo form copiando il codice html...... se qualcuno m puo' dire dove sbaglio?


questo è il codice

<?php
// L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
$to = "destinataro";

// IL SOGGETTO DELLA MAIL
$subject = "Modulo proveniente dal sito www.sito.it";

// COSTRUZIONE DEL CORPO DEL MESSAGGIO
$body = "Contenuto del modulo:\n\n";

$body .= "Dati personali nome: " . trim(stripslashes($_POST["nome"])) . "\n";
$body .= "cognome: " . trim(stripslashes($_POST["cognome"])) . "\n";
$body .= "Città: " . trim(stripslashes($_POST["citta"])) . "\n";
$body .= "Oggetto: " . trim(stripslashes($_POST["oggetto"])) . "\n";
$body .= "testo: " . trim(stripslashes($_POST["testo"])) . "\n";
$body .= "mail: " . trim(stripslashes($_POST["mail"])) . "\n";

// INTESTAZIONI SUPPLEMENTARI
$headers = "From: Modulo utenti<INDIRIZZO-COME-SOPRA>";
?>
<html>
<head>
<title>La mia email HTML</title>
<style type="text/css">
body {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; font-weight:normal; color:#000000;}
</style>
</head>
<body>
<p>Ecco la mia prima mail in HTML.<br>
Questo testo è in <strong>bold</strong></p>
<p>E qui ci metto una immagine: <img src="miosito.jpeg"></p>
</body>
</html>


<?php


// INVIO DELLA MAIL
if(@mail($to, $subject, $body, $headers)) { // SE L'INOLTRO E' ANDATO A BUON FINE...

echo "La mail è stata inoltrata con successo.";

} else {// ALTRIMENTI...

echo "Si sono verificati dei problemi nell'invio della mail.";

}

?>

IAmZak
04-12-2009, 15:01
ti mando una struttura sicuramente funzionante che mi ti farà sbagliare:


$email_riceve="Pinco pallino <pincopallino@blablabla.it>";
$message = "
<html>
<head>
<title>EMAIL</title>
<style type=\"text/css\">
<!--
scegliteli te
-->
</style>
</head>
<body>
<table width=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td>
<p>Ciao ciao questa è una mail</p>
</td>
</tr>
</table>
</body>
</html>
";}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From:<arturo@casa.it>\n";
mail($email_riceve,"Oggetto della mail",$message, $headers);
}}


ricordati che:
1) metti gli \ prima dei " perchè se no php non fà l'escape del carattere
2) fai l'email come se fosse una tabella, se non non riescono a leggerla tutti (esempio outlook che usa il motore di word)