3 // example on using PHPMailer with GMAIL
\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
8 $mail = new PHPMailer();
\r
10 $body = $mail->getFile('contents.html');
\r
11 $body = eregi_replace("[\]",'',$body);
\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
19 $mail->Username = "yourname@gmail.com"; // GMAIL username
\r
20 $mail->Password = "password"; // GMAIL password
\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
28 $mail->MsgHTML($body);
\r
30 $mail->AddReplyTo("replyto@yourdomain.com","Webmaster");
\r
32 $mail->AddAttachment("/path/to/file.zip"); // attachment
\r
33 $mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment
\r
35 $mail->AddAddress("username@domain.com","First Last");
\r
37 $mail->IsHTML(true); // send as HTML
\r
39 if(!$mail->Send()) {
\r
40 echo "Mailer Error: " . $mail->ErrorInfo;
\r
42 echo "Message has been sent";
\r