Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

biza

[Resolvido] Envio de email

Recommended Posts

Ola pessoal estou com uma duvida...

Será que é possível ao enviar um email ao destinatário, os dados em forma de tabela , tipo linhas e colunas....

Se sim como posso fazer.

obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

Com a própria função mail() é possível o envio de email no formato HTML. Código abaixo retirado de php.net

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
 <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
 <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
 <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

/* Atenção se você pretende inserir numa variável uma mensagem html mais
complexa do que essa sem precisar escapar os carateres 
necessários pode ser feito o uso da sintaxe heredoc, consulte tipos-string-sintaxe-heredoc */

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

 

Está definido no cabeçalho o tipo:

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

Vlw

Compartilhar este post


Link para o post
Compartilhar em outros sites

caro amigo root

Dev informalo de que testei a forma que você me enviou e não envia par o destino como uma tabela o código apos o html aparece

 

<html>

<head>

<title>Birthday Reminders for August</title>

</head>

<body>

<p>Here are the birthdays upcoming in August!</p>

<table>

<tr>

<th>Person</th><th>Day</th><th>Month</th><th>Year</th>

</tr>

<tr>

<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>

</tr>

<tr>

<td>Sally</td><td>17th</td><td>August</td><td>1973</td>

</tr>

</table>

</body>

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você definiu os headers direitinho exatamente como ele fez?

 

Um email por padrao é enviado em plain text(TXT), você deve definir no header do email que ele deve interpetrar como html..

 

Bom resumindo você colocou os $headers rsrs?

 

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.