Posted: Sun Jan 25, 2004 9:43 pm
hi there ppl,
i'm trying to send an email with the php mail() function, but the email is delivered with no content, here's the code that i'm using
thanks for your time, any sugestion??
best regards
Pedro Afonso
i'm trying to send an email with the php mail() function, but the email is delivered with no content, here's the code that i'm using
Code: Select all
function fimEncomenda(){
$email = $_GETї'email'];
$acesso = ligarBD();
$mime_boundary = "<<<:" . md5(uniqid(mt_rand(), 1));
if($acesso && isset($_SESSIONї'items']))
{
$content = "This is a multi-part message in MIME format.\r\n\r\n";
$content.= "--".$mime_boundary."\r\n";
$content.= "Content-Type: text/html; charset="iso-8859-1"\r\n";
$content.= "Content-Transfer-Encoding: 7bit\r\n";
$content.= "<html>
<body>
<center>
<table width='60%' border='0'>
<tr>
<td height='39' bgcolor='#0099CC'>
<h1><center><font color='#FFFFFF'>Musica (ON)Line</font></center></h1>
</td>
</tr>
</table>";
$content.="<table width='60%' border='1'> <tr><th> </th><th>Código</th><th>Album</th><th>Artista</th><th>Preço</th> </tr>";
mysql_select_db('arg08') or die("Base de dados inválida");
$total=0;
for($i=0;$i<count($_SESSIONї'items']);$i++){
$query = "select * from produtos where codigo = ". $_SESSIONї'items']ї$i] ;
$resultado_query = mysql_query($query);
$codigo=mysql_result($resultado_query,0,"codigo");
//$data = chunk_split(base64_encode(implode("", file("imagens/".$codigo."p.jpg"))));
$data = base64_encode(implode("", file("imagens/".$codigo."p.jpg")));
$album=mysql_result($resultado_query,0,"album");
$artista=mysql_result($resultado_query,0,"artista");
$preco=mysql_result($resultado_query,0,"preco");
$query2 = "insert into encomendas values($codigo,'$artista','$album',$preco,'$email')" ;
$result = mysql_query($query2) or die(mysql_error());
$content.="<tr><td align='center'>\r\n";
$content.= "--".$mime_boundary."\r\n";
$content .= "Content-Type: image/jpeg;\r\n";
$content .= "Content-Transfer-Encoding: base64\r\n";
$content.= $data."\r\n";
$content.= "--".$mime_boundary."\r\n";
$content.= "Content-Type: text/html; charset="iso-8859-1"\r\n";
$content.= "Content-Transfer-Encoding: 7bit\r\n";
$content .="</td><td align='center'>".$codigo."</td><td align='center'>".$album."</td><td align='center'>".$artista."</td><td align='center'>€ ".$preco."</td></tr>";
$total+=$preco;
}
$content.="</table>";
$content .="O total da sua encomenda é de : € ".$total;
$content .="<br> Obrigado pela sua Preferência. <a href='http://menace00.no-ip.com/web/tp/index.php'>Visite-nos</a></center>\r\n";
$content.= "--".$mime_boundary."--\r\n";
$header = "From: Musica Online<muscicaonline@musiconline.pt>\n";
$header.= "To: ".$email."\n";
$header.= "MIME-Version: 1.1\n";
$header.= "Content-Type: multipart/mixed;";
$header.= "boundary="".$mime_boundary.""\r\n";
mail($email,"Encomenda efectuda",$content,$header);
?>
<table align="center"bgcolor="#b8e4ed"><tr><td>A sua Encomenda foi efectuado com sucesso , clique <a href ="index.php">aqui</a> para voltar ao início<br><center>Verifique a sua caixa de correio para visualizar os dados da encomenda.</center>
</td></tr>
</table>
<?php
session_destroy();
mysql_close();
}else{?>
<table align="center" bgcolor="#b8e4ed"><tr><td>A sua Encomenda não pode ser efectuada de momento,por favor <a href="index.php?carrinho=1"> tente novamente</a> ou clique <a href ="index.php">aqui</a> para voltar ao início
</td></tr>
</table>
<?php
}
}best regards
Pedro Afonso