Re-added
[mailer.git] / inc / phpmailer / examples / index.html
1 <p>The example file &quot;test_mail.php&quot; contents include:</p>\r
2 <div style="width: 600px; background-color: #CCCCCC;">\r
3 <code>\r
4 &lt;?php<br>\r
5 <br>\r
6 include_once('../class.phpmailer.php');<br>\r
7 <br>\r
8 $mail    = new PHPMailer();<br>\r
9 <br>\r
10 $body    = $mail->getFile('contents.html');<br>\r
11 <br>\r
12 $body    = eregi_replace("[\]",'',$body);<br>\r
13 $subject = eregi_replace("[\]",'',$subject);<br>\r
14 <br>\r
15 $mail->From     = "name@yourdomain.com";<br>\r
16 $mail->FromName = "First Last";<br>\r
17 <br>\r
18 $mail->Subject = "PHPMailer Test Subject";<br>\r
19 <br>\r
20 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test<br>\r
21 <br>\r
22 $mail->MsgHTML($body);<br>\r
23 <br>\r
24 $mail->AddAddress("whoto@otherdomain.com", "John Doe");<br>\r
25 <br>\r
26 if(!$mail->Send()) {<br>\r
27   echo 'Failed to send mail';<br>\r
28 } else {<br>\r
29   echo 'Mail sent';<br>\r
30 }<br>\r
31 <br>\r
32 ?&gt;\r
33 </code>\r
34 </div>\r
35 <br>\r
36 Although you could use full compabitility with PHPMailer 1.7.3, this example\r
37 shows how to use the new features. If you view 'contents.html', you will note\r
38 that there is a background image used in the &lt;body tag as well as an image used\r
39 with a regular &lt;img tag. Here&#39;s what the HTML file looks like:<br>\r
40 <br>\r
41 <div style="width: 600px; background-color: #CCCCCC;">\r
42 <code>\r
43 &lt;body background="images/bkgrnd.gif" style="margin: 0px;"&gt;<br>\r
44 &lt;div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;"&gt;<br>\r
45 &lt;div align="center"&gt;&lt;img src="images/phpmailer.gif" style="height: 90px; width: 340px"&gt;&lt;/div&gt;&lt;br&gt;<br>\r
46 &lt;br&gt;<br>\r
47 &nbsp;This is a test of PHPMailer v2.0.0 rc1.&lt;br&gt;<br>\r
48 &lt;br&gt;<br>\r
49 This particular example uses &lt;strong&gt;HTML&lt;/strong&gt;, with a &lt;div&gt; tag and inline&lt;br&gt;<br>\r
50 styles.&lt;br&gt;<br>\r
51 &lt;br&gt;<br>\r
52 Also note the use of the PHPMailer at the top with no specific code to handle<br>\r
53 including it in the body of the email.&lt;/div&gt;<br>\r
54 &lt;/body&gt;<br>\r
55 </code>\r
56 </div>\r
57 <br>\r
58 A few things to notice in the PHP script that generates the email:\r
59 <ul>\r
60   <li>the use of $mail-&gt;AltBody is completely optional. If not used, PHPMailer\r
61   will use the HTML text with htmlentities().</li>\r
62   <li>the background= and &lt;img src= images were processed without any directives\r
63   or methods from the PHP script</li>\r
64   <li>there is no specific code to define the image type ... that is handled\r
65   automatically by PHPMailer when it parses the images</li>\r
66   <li>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</li>\r
67 </ul>\r
68 <p>Of course, you can still use PHPMailer the same way you have in the past.\r
69 That provides full compatibility with all existing scripts, while new scripts\r
70 can take advantage of the new features.</p>\r
71 <p>Modify test_mail.php now with your own email address and try it out.</p>\r
72 To see what the email SHOULD look like in your HTML compatible email viewer: <a href="contents.html">click here</a><br>\r
73 \r