Re-added
[mailer.git] / inc / phpmailer / examples / test_gmail.php
1 <?php\r
2 \r
3 include("class.phpmailer.php");\r
4 //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded\r
5 \r
6 $mail             = new PHPMailer();\r
7 \r
8 $body             = $mail->getFile('contents.html');\r
9 $body             = eregi_replace("[\]",'',$body);\r
10 \r
11 $mail->IsSMTP();\r
12 $mail->SMTPAuth   = true;                  // enable SMTP authentication\r
13 $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier\r
14 $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server\r
15 $mail->Port       = 465;                   // set the SMTP port for the GMAIL server\r
16 \r
17 $mail->Username   = "yourusername@gmail.com";  // GMAIL username\r
18 $mail->Password   = "yourpassword";            // GMAIL password\r
19 \r
20 $mail->AddReplyTo("yourusername@gmail.com","First Last");\r
21 \r
22 $mail->From       = "name@yourdomain.com";\r
23 $mail->FromName   = "First Last";\r
24 \r
25 $mail->Subject    = "PHPMailer Test Subject via gmail";\r
26 \r
27 //$mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body\r
28 $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test\r
29 $mail->WordWrap   = 50; // set word wrap\r
30 \r
31 $mail->MsgHTML($body);\r
32 \r
33 $mail->AddAddress("whoto@otherdomain.com", "John Doe");\r
34 \r
35 $mail->AddAttachment("images/phpmailer.gif");             // attachment\r
36 \r
37 $mail->IsHTML(true); // send as HTML\r
38 \r
39 if(!$mail->Send()) {\r
40   echo "Mailer Error: " . $mail->ErrorInfo;\r
41 } else {\r
42   echo "Message sent!";\r
43 }\r
44 \r
45 ?>\r