Re-added
[mailer.git] / inc / phpmailer / docs / use_gmail.txt
1 <?php\r
2 \r
3 // example on using PHPMailer with GMAIL\r
4 \r
5 include("class.phpmailer.php");\r
6 include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded\r
7 \r
8 $mail             = new PHPMailer();\r
9 \r
10 $body             = $mail->getFile('contents.html');\r
11 $body             = eregi_replace("[\]",'',$body);\r
12 \r
13 $mail->IsSMTP();\r
14 $mail->SMTPAuth   = true;                  // enable SMTP authentication\r
15 $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier\r
16 $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server\r
17 $mail->Port       = 465;                   // set the SMTP port\r
18 \r
19 $mail->Username   = "yourname@gmail.com";  // GMAIL username\r
20 $mail->Password   = "password";            // GMAIL password\r
21 \r
22 $mail->From       = "replyto@yourdomain.com";\r
23 $mail->FromName   = "Webmaster";\r
24 $mail->Subject    = "This is the subject";\r
25 $mail->AltBody    = "This is the body when user views in plain text format"; //Text Body\r
26 $mail->WordWrap   = 50; // set word wrap\r
27 \r
28 $mail->MsgHTML($body);\r
29 \r
30 $mail->AddReplyTo("replyto@yourdomain.com","Webmaster");\r
31 \r
32 $mail->AddAttachment("/path/to/file.zip");             // attachment\r
33 $mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment\r
34 \r
35 $mail->AddAddress("username@domain.com","First Last");\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 has been sent";\r
43 }\r
44 \r
45 ?>\r