source: hadoop-register/etc/phpMailer/examples/test_gmail.php @ 261

Last change on this file since 261 was 57, checked in by jazz, 16 years ago
  • 第一版 Hadoop 叢集之帳號申請網頁 by Wade
File size: 1.6 KB
RevLine 
[57]1<?php
2
3//error_reporting(E_ALL);
4error_reporting(E_STRICT);
5
6date_default_timezone_set('America/Toronto');
7
8include("class.phpmailer.php");
9//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
10
11$mail             = new PHPMailer();
12
13$body             = $mail->getFile('contents.html');
14$body             = eregi_replace("[\]",'',$body);
15
16$mail->IsSMTP();
17$mail->SMTPAuth   = true;                  // enable SMTP authentication
18$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
19$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
20$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
21
22$mail->Username   = "yourusername@gmail.com";  // GMAIL username
23$mail->Password   = "yourpassword";            // GMAIL password
24
25$mail->AddReplyTo("yourusername@gmail.com","First Last");
26
27$mail->From       = "name@yourdomain.com";
28$mail->FromName   = "First Last";
29
30$mail->Subject    = "PHPMailer Test Subject via gmail";
31
32//$mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body
33$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
34$mail->WordWrap   = 50; // set word wrap
35
36$mail->MsgHTML($body);
37
38$mail->AddAddress("whoto@otherdomain.com", "John Doe");
39
40$mail->AddAttachment("images/phpmailer.gif");             // attachment
41
42$mail->IsHTML(true); // send as HTML
43
44if(!$mail->Send()) {
45  echo "Mailer Error: " . $mail->ErrorInfo;
46} else {
47  echo "Message sent!";
48}
49
50?>
Note: See TracBrowser for help on using the repository browser.