View Full Version : dúvida a enviar mail via php


fil79
10-01-2008, 01:59
Boas

tenho este código para enviar mail:


$corpo= "
<html>
<body>
<table width='378' border='5' bordercolor='#000066'>
<tr>
<th width='145' scope='row'><img src='http://www........../.....jpg' width='100' height='39' /></th>
<td width='217'>".$_POST['nome']."</td>
</tr>
<tr>
<th scope='row'>Telefone</th>
<td>".$_POST['telefone']."</td>
</tr>
<tr>
<th scope='row'>Local</th>
<td>".$_POST['local']."</td>
</tr>
<tr>
<th scope='row'>Hora</th>
<td>".$_POST['hora']."</td>
</tr>
<tr>
<th scope='row'>Dia</th>
<td>".$_POST['dia']."</td>
</tr>
<tr>
<th scope='row'>Notas</th>
<td>".$_POST['notas']."</td>
</tr>
</table>
".$fofoca."

</body>
</html>";

$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From:".$_POST['nome']."\n";


$to = "algo@gmail.com";

$subject = "Mensagem de ".$_POST["nome"]." ";

$message = $corpo;



mail($to, $subject, $message, $headers);

echo "<script> window.alert('A sua mensagem foi enviada.!')</script>"


;



o script funciona bem mas queria que fosse adicionada uma imagem no mail... usei esta tg html <img src='http://www........../.....jpg' mas não aparece a imagem...já verifiquei e a path está correcta...sugestões? Desde já agradeço!

fil79
10-01-2008, 13:25
alguém???

s31s3r
10-01-2008, 13:33
Não te sei explicar bem, mas dá uma boa leitura em http://www.phpbuilder.com/columns/kartic20000807.php3?page=1

fil79
11-01-2008, 12:01
já li e reli este artigo e outros....o problema continua

p3dro
11-01-2008, 12:37
já li e reli este artigo e outros....o problema continua

Dá uma vista de olhos no phpmailer (http://phpmailer.codeworxtech.com/)

fil79
11-01-2008, 15:49
A classe é muito boa... já consigo enviar imagens mas assim surgiu outra dúvida:




include_once('class.phpmailer.php');

$mail = new PHPMailer();

$body = $mail->getFile('conteudo.txt');

$body = eregi_replace("[\]",'',$body);

$mail->From = "name@yourdomain.com";
$mail->FromName = $_POST['nome'];

$mail->Subject = "PHPMailer Test Subject";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAddress("filipe79@gmail.com", "Ana ");

if(!$mail->Send()) {
echo 'Failed to send mail';
} else {
echo 'Mail sent';
}


$fp = fopen("conteudo.txt", "w+");

$texto="<html>
<body>
<table width='378' border='5' bordercolor='#000066'>
<tr>
<th width='145' scope='row'><img src=\"http://www.a-courela.com/ana/imagens/paciente.jpg\" /></th>
<td width='217'>".$nomefinal."</td>
</tr>
<tr>
<th scope='row'>Telefone</th>
<td>".$_POST['telefone']."</td>
</tr>
<tr>
<th scope='row'>Local</th>
<td>".$_POST['local']."</td>
</tr>
<tr>
<th scope='row'>Hora</th>
<td>".$_POST['hora']."</td>
</tr>
<tr>
<th scope='row'>Dia</th>
<td>".$_POST['dia']."</td>
</tr>
<tr>
<th scope='row'>Notas</th>
<td>".$_POST['notas']."</td>
</tr>
</table>

<br>

</body>
</html>";


$escrever=fwrite($fp,$texto);






esta classe envia os dados num txt...criei também um codigo que escreve os dados nesse txt...Mas assim envia primeiro os dados num txt vazio e só depois escreve...como posso fazer para o script executar primeiro a escrita do txt e só depois enviar esse mesmo txt pelo mail? Espero que me tenha feito entender..