Mail function formatting?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Mail function formatting?

Post by spacebiscuit »

Hi,

I am using the mail php function. Is it possible to add formatting to the body email text?

Many thanks in advacne,

Rob.
scriptah
Forum Commoner
Posts: 27
Joined: Sat Mar 15, 2008 8:58 pm
Location: Long Island, NY

Re: Mail function formatting?

Post by scriptah »

spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Mail function formatting?

Post by spacebiscuit »

Perfect thanks!

Rob.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Mail function formatting?

Post by spacebiscuit »

I am following example 4 but I am having trouble displaying ph data in my email, is this possible with this method?

Here is my example code:

Code: Select all

$to = "$email";
$subject = "Example e-mail testing";
 
$body='
<html>
<head>
</head>
<body>
  <p>Hello $name - this is a test....</p>    
</body>
</html>';
 
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
mail($to, $subject, $body, $headers);
When I receive the email the php data is not displayed, I just see the variable name.

Any ideas?

Thanks,

Rob.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Mail function formatting?

Post by spacebiscuit »

I solved the problem, I had to change the quote to a double quotation as follows:

Code: Select all

$body='
to..

Code: Select all

$body="
Thanks,

Rob.
Post Reply