Ciao a tutti,
ho questa pagina che in teoria dovrebbe spedire un e-mail generata da un form ad una lista; la mail in formato html dovrebbe contenere un 'immagine di background ma purtroppo l'immagine me la allega e perdo il testo della mail
![]()
come posso fare? grazie...
![]()
questo è il codice in questione, penso sia un problema con la definizione del linguaggio della mail...
$email = "prova@nettunosrl.it";
$e=&$email; /*Inserire l'indirizzo email a cui si vuole spedire l'email*/
$ogg = $_POST['oggetto_email']; /*ITALIANO Inserire l'oggetto dell'email da spedire*/
$mittente="prova@nettunosrl.it"; /*Inserire l'indirizzo email che verrà visulaizzato come mittente dell'email*/
$reply = "prova@nettunosrl.it";
/*Non modificare nulla al di sotto di questa linea*/
$boundary = "==String_Boundary_x" .md5(time()). "x"; // SEZIONE IMMAGINI
$boundary2 = "==String_Boundary2_y" .md5(time()). "y"; //SEZIONE TXT
$intestazioni = "From: $mittente\nReply-To: $reply\nBcc: $email\nX-Mailer: Sismail Web Email Interface\nMIME-version: 1.0\n"; //Content-type: text/html;charset=iso-8859-1\n\n
$intestazioni .= "Content-Type: multipart/related;\n";
$intestazioni .= " type=\"multipart/alternative\";\n";
$intestazioni .= " boundary=\"$boundary\";\n\n";
// il primo segmento del multipart/related
// è definito come multipart/alternative
$mess .= "--$boundary\n";
$mess .= "Content-Type: multipart/alternative;\n";
$mess .= " boundary=\"$boundary2\";\n\n";
// sezione alternativa in puro testo
$mess .= "--$boundary2\n";
$mess .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$mess .= "Content-Transfer-Encoding: 7bit\n\n";
$mess .= strip_tags($_POST['corpo_mail']) . "\n\n";
// sezione alternativa in formato html
$mess .= "--$boundary2\n";
$mess .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$mess .= "Content-Transfer-Encoding: 7bit\n\n";
/* Nella variabile $mess va inserito tutto il codice html che comporrà il corpo dell'email
/* che si vuole inviare. Si possono utilizzare anche i fogli di stile.*/
$mess = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\r\n";
$mess .= "<HTML>\r\n";
$mess .= "<HEAD> \r\n";
$mess .= "<META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">\r\n";
$mess .= "<STYLE>\r\n";
$mess .= "<!--\r\n";
$mess .= "H5 {text-align: justify; text-decoration: none; color: #333333; font-size: 12px; font-family: Arial}\r\n";
$mess .= "A:link, A:visited, A:hover { color: #FFcc00 }\r\n";
$mess .= "-->\r\n";
$mess .= "</STYLE>\r\n";
$mess .= "</HEAD>\r\n";
$mess .= "<BODY bgColor=#ffffff link=#333333 alink=#333333 vlink=#333333>\r\n";
$mess .= "<div>\r\n";
$mess .= "<table>\r\n";
$mess .= "<tr>\r\n";
$mess .= "<td background=\"'cid:MiaImmagine123\" style=' background-repeat: no-repeat; background-attachment: scroll;'>\r\n";
$mess .= $_POST['corpo_mail'] . "\r\n";
$mess .= "<td>\r\n";
$mess .= "</tr>\r\n";
$mess .= "</table>\r\n";
$mess .= "</div>\r\n";
$mess .= "</BODY>\r\n";
$mess .= "</HTML>\r\n";
// chiusura della sezione multipart/alternative
$mess .= "--$boundary2--\n";
// costruiamo la sezione contenente l'immagine
// cui attribuiamo l'id MiaImmagine123
$mess .= "--$boundary\n";
$mess .= "Content-ID: <MiaImmagine123>\n";
$mess .= "Content-Type: image/jpeg\n";
$mess .= "Content-Transfer-Encoding: base64\n\n";
// leggiamo il file corrispondente all'immagine dal nostro server
$allegato = "./img/sfondo_email.jpg";
$file = fopen($allegato,'rb');
$data = fread($file,filesize($allegato));
fclose($file);
// usiamo la codifica base64 per trasmettere il file
$data = chunk_split(base64_encode($data));
$mess .= "$data\n\n";
// chiusura del messaggio con la stringa boundary
$mess .= "--$boundary--\n";
$mess = trim($mess);
$msg_body = $mess;
echo "<html>\n";
echo "<head>\n";
echo "<meta http-equiv='content-type' content='text/html;charset=ISO-8859-1'>\n";
echo "<title>invio Mail</title>\n";
echo "<script language='JavaScript'>\n";
echo "<!--\n";
echo "function fine(){\n";
echo "var funzione = \"document.location.href='mail.php'\";\n";
echo "var tempo = setTimeout(funzione,5000);\n";
echo "}\n";
echo "// -->\n";
echo "</script>\n";
echo "<style media='screen' type='text/css'>\n";
echo "<!--\n";
echo ".verdana {font-weight:normal;font-size:9px;font-family:Verdana;text-decoration:none;}\n";
echo ".giust {text-align:justify;}\n";
echo "-->\n";
echo "</style>\n";
echo "</head>\n\n";
//echo $mittente . "
" . $ogg . "
" . $msg_body . "
" . $intestazioni . "
";
//exit;
echo "<body bgcolor='#ffffff' marginheight='0' marginwidth='0' onload='fine();' leftmargin='0' topmargin='0' link='white' alink='white' vlink='white'>\n";
echo "<table width='100%' height='100%' border='0' cellpadding='2' cellspacing='0'>\n";
if(!(@mail($mittente,$ogg,$msg_body, $intestazioni))){
echo "<tr>\n";
echo "<td height='100%' align='center' valign='middle' colspan='2'>\n";
print "<H5 style='color:#CC0000;'>Invio della email fallito.</H5>";
echo "</td>\n";
echo "</tr>\n";
} else {
echo "<tr>\n";
echo "<td height='100%' align='center' valign='middle' colspan='2'>\n";
print "<H5 style='color:#00CC00;'>Invio della email eseguito correttamente.</H5>";
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "</body>\n";
echo "</html>\n";
exit;
}