3 // example on using PHPMailer with GMAIL
5 include("class.phpmailer.php");
6 include("class.smtp.php");
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
16 $mail->Username = "yourname@gmail.com"; // GMAIL username
17 $mail->Password = "password"; // GMAIL password
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
25 $mail->WordWrap = 50; // set word wrap
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
32 $mail->IsHTML(true); // send as HTML
35 echo "Mailer Error: " . $mail->ErrorInfo;
37 echo "Message has been sent";