Hello, first of all, thanks for the help.
I recently created a mail part at my website, the user can send an email to somebody, a simple mail system. The problem are the attach´s. I can send the attach via mail, but the message, the content part, don´t send togheter.
Ps: At outlook, I just receive the attach and nothing else, the message is not coming togheter,
Can someone help me??
<?php
session_start();
?>
<script language="JavaScript" type="text/javascript">
var arrOldValues;
function SelectAllList(CONTROL){
for(var i = 0;i < CONTROL.length;i++){
CONTROL.options[i].selected = true;
}
}
function DeselectAllList(CONTROL){
for(var i = 0;i < CONTROL.length;i++){
CONTROL.options[i].selected = false;
}
}
function FillListValues(CONTROL){
var arrNewValues;
var intNewPos;
var strTemp = GetSelectValues(CONTROL);
arrNewValues = strTemp.split(",");
for(var i=0;i<arrNewValues.length-1;i++){
if(arrNewValues[i]==1){
intNewPos = i;
}
}
for(var i=0;i<arrOldValues.length-1;i++){
if(arrOldValues[i]==1 && i != intNewPos){
CONTROL.options[i].selected= true;
} else if(arrOldValues[i]==0 && i != intNewPos){
CONTROL.options[i].selected= false;
}
if(arrOldValues[intNewPos]== 1){
CONTROL.options[intNewPos].selected = false;
} else {
CONTROL.options[intNewPos].selected = true;
}
}
}
function GetSelectValues(CONTROL){
var strTemp = "";
for(var i = 0;i < CONTROL.length;i++){
if(CONTROL.options[i].selected == true){
strTemp += "1,";
} else {
strTemp += "0,";
}
}
return strTemp;
}
function GetCurrentListValues(CONTROL){
var strValues = "";
strValues = GetSelectValues(CONTROL);
arrOldValues = strValues.split(",")
}
</script>
<?php
include ("conecta.php");
if ($acao==add)
{
$gru=$_POST["gru"];
for ($i=0;$i<count($gru);$i++)
{
$grupo .= "$gru[$i] ";
}
// Converte strings
$texto = $_POST['texto'];
// Atualiza no banco de dados
$filename = $_FILES["strresume"]["name"];
$filetype = $_FILES["strresume"]["type"];
$filesize = $_FILES["strresume"]["size"];
$filetemp = $_FILES["strresume"]["tmp_name"];
$remetente = "$nickuser"."@yachtbrasil.com.br";
$fp = fopen($strresume, "rb");
$file = fread($fp, $strresume_size);
$file = chunk_split(base64_encode($file));
$num = md5(time());
$headers = "From: $remetente\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; ";
$headers .= "boundary=".$num."\r\n";
$headers .= "--$num\r\n";
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
$headers .= "X-Mailer: PHP v".phpversion()."\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "Content-Type:".$strresume_type." ";
$headers .= "name=\"".$strresume_name."\"r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Disposition: attachment; ";
$headers .= "filename=\"".$strresume_name."\"\r\n\n";
$headers .= "".$file."\r\n";
$headers .= "--".$num."--";
$body = "<table width='350' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='350'><img src='http://www.yachtbrasil.com.br/ftp/branco.jpg' width='350' height='143'></td>
</tr>
<tr>
<td height='56'>$texto</td>
</tr>
</table>";
$dataa = date("d/m/y");
$sql = mysql_query("Select * From usuarios where perm='nao'");
if ($todos != "sim") {
while($valor = mysql_fetch_array($sql)){
$nick = "$valor[nick]";
$destino = "rodrigoferrari"."@yachtbrasil.com.br";
if (substr_count($grupo, "$nick") == 1) {
$email = mail("$destino", "$assunto", "$body", "$headers");
fclose($fp);
if($email){
echo("
<script>
alert(\"E-mail enviado com sucesso\");
window.location = 'addmensagem.php';
</script>");
} else {
echo("<script>
alert(\"Não foi possível enviar o e-mail, tente novamente\");
window.location = 'javascript:history.back(-1)';
</script>");
}
}
}
} elseif ($todos == "sim") {
while($valor = mysql_fetch_array($sql)){
$nick = "$valor[nick]";
$destino = "$valor[nick]"."@yachtbrasil.com.br";
$email = mail("$destino", "$assunto", "$body", "$headers");
if($email){
echo("
<script>
alert(\"E-mail enviado com sucesso\");
window.location = 'addmensagem.php';
</script>");
} else {
echo("<script>
alert(\"Não foi possível enviar o e-mail, tente novamente\");
window.location = 'javascript:history.back(-1)';
</script>");
}
}
}
}?>
Thanks!