The example file "test1.php" contents include:

`<?php
include_once('../class.phpmailer.php');
$mail = new PHPMailer();
$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);
$subject = eregi_replace("[\]",'',$subject);
$mail->From = "name@yourdomain.com";
$mail->FromName = "First Last";
$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("whoto@otherdomain.com", "John Doe");
if(!$mail->Send()) {
echo 'Failed to send mail';
} else {
echo 'Mail sent';
}
?>`
Although you could use full compabitility with PHPMailer 1.7.3, this example shows how to use the new features. If you view 'contents.html', you will note that there is a background image used in the <body tag as well as an image used with a regular <img tag. Here's what the HTML file looks like:
`<body background="images/bkgrnd.gif" style="margin: 0px;">
<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
<div align="center"><img src="images/phpmailer.gif" style="height: 90px; width: 340px"></div><br>
<br>
This is a test of PHPMailer v2.0.0 rc1.<br>
<br>
This particular example uses <strong>HTML</strong>, with a <div> tag and inline<br>
styles.<br>
<br>
Also note the use of the PHPMailer at the top with no specific code to handle
including it in the body of the email.</div>
</body>
`
A few things to notice in the PHP script that generates the email:

- the use of $mail->AltBody is completely optional. If not used, PHPMailer will use the HTML text with htmlentities().
- the background= and <img src= images were processed without any directives or methods from the PHP script
- there is no specific code to define the image type ... that is handled automatically by PHPMailer when it parses the images
- we are using a new class method '$mail->MsgHTML($body)' ... that is what will handle the parsing of the images and creating the AltBody text

Of course, you can still use PHPMailer the same way you have in the past. That provides full compatibility with all existing scripts, while new scripts can take advantage of the new features.

Modify test1.php now with your own email address and try it out.

To see what the email SHOULD look like in your HTML compatible email viewer: click here