svn:eol-style set to 'native'
[mailer.git] / inc / phpmailer / examples / test_smtp.php
1 <?php
2
3 include_once('class.phpmailer.php');
4 //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
5
6 $mail             = new PHPMailer();
7
8 $body             = $mail->getFile('contents.html');
9 $body             = eregi_replace("[\]",'',$body);
10
11 $mail->IsSMTP(); // telling the class to use SMTP
12 $mail->Host       = "mail.yourdomain.com"; // SMTP server
13
14 $mail->From       = "name@yourdomain.com";
15 $mail->FromName   = "First Last";
16
17 $mail->Subject    = "PHPMailer Test Subject via smtp";
18
19 $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
20
21 $mail->MsgHTML($body);
22
23 $mail->AddAddress("whoto@otherdomain.com", "John Doe");
24
25 $mail->AddAttachment("images/phpmailer.gif");             // attachment
26
27 if(!$mail->Send()) {
28   echo "Mailer Error: " . $mail->ErrorInfo;
29 } else {
30   echo "Message sent!";
31 }
32
33 ?>