test_gmail.php

Go to the documentation of this file.
00001 <?php
00002 
00003 //error_reporting(E_ALL);
00004 error_reporting(E_STRICT);
00005 
00006 date_default_timezone_set('America/Toronto');
00007 
00008 include("class.phpmailer.php");
00009 //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
00010 
00011 $mail             = new PHPMailer();
00012 
00013 $body             = $mail->getFile('contents.html');
00014 $body             = eregi_replace("[\]",'',$body);
00015 
00016 $mail->IsSMTP();
00017 $mail->SMTPAuth   = true;                  // enable SMTP authentication
00018 $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
00019 $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
00020 $mail->Port       = 465;                   // set the SMTP port for the GMAIL server
00021 
00022 $mail->Username   = "yourusername@gmail.com";  // GMAIL username
00023 $mail->Password   = "yourpassword";            // GMAIL password
00024 
00025 $mail->AddReplyTo("yourusername@gmail.com","First Last");
00026 
00027 $mail->From       = "name@yourdomain.com";
00028 $mail->FromName   = "First Last";
00029 
00030 $mail->Subject    = "PHPMailer Test Subject via gmail";
00031 
00032 //$mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body
00033 $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
00034 $mail->WordWrap   = 50; // set word wrap
00035 
00036 $mail->MsgHTML($body);
00037 
00038 $mail->AddAddress("whoto@otherdomain.com", "John Doe");
00039 
00040 $mail->AddAttachment("images/phpmailer.gif");             // attachment
00041 
00042 $mail->IsHTML(true); // send as HTML
00043 
00044 if(!$mail->Send()) {
00045   echo "Mailer Error: " . $mail->ErrorInfo;
00046 } else {
00047   echo "Message sent!";
00048 }
00049 
00050 ?>

Generated on Mon Dec 8 01:06:46 2008 for Ship-Simulator by  doxygen 1.5.6