3f384eb0dabe1b64bc91f6219e5a604e79cac2ce
[mailer.git] / inc / phpmailer / docs / use_gmail.txt
1 <?php
2
3 // example on using PHPMailer with GMAIL 
4
5 include("class.phpmailer.php");
6 include("class.smtp.php");
7
8 $mail=new PHPMailer();
9
10 $mail->IsSMTP();
11 $mail->SMTPAuth   = true;                  // enable SMTP authentication
12 $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
13 $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
14 $mail->Port       = 465;                   // set the SMTP port 
15
16 $mail->Username   = "yourname@gmail.com";  // GMAIL username
17 $mail->Password   = "password";            // GMAIL password
18
19 $mail->From       = "replyto@yourdomain.com";
20 $mail->FromName   = "Webmaster";
21 $mail->Subject    = "This is the subject";
22 $mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body
23 $mail->AltBody    = "This is the body when user views in plain text format"; //Text Body
24
25 $mail->WordWrap   = 50; // set word wrap
26
27 $mail->AddAddress("username@domain.com","First Last");
28 $mail->AddReplyTo("replyto@yourdomain.com","Webmaster");
29 $mail->AddAttachment("/path/to/file.zip");             // attachment
30 $mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment
31
32 $mail->IsHTML(true); // send as HTML
33
34 if(!$mail->Send()) {
35   echo "Mailer Error: " . $mail->ErrorInfo;
36 } else {
37   echo "Message has been sent";
38 }
39
40 ?>