test_gmail.php
Go to the documentation of this file.00001 <?php
00002
00003
00004 error_reporting(E_STRICT);
00005
00006 date_default_timezone_set('America/Toronto');
00007
00008 include("class.phpmailer.php");
00009
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;
00018 $mail->SMTPSecure = "ssl";
00019 $mail->Host = "smtp.gmail.com";
00020 $mail->Port = 465;
00021
00022 $mail->Username = "yourusername@gmail.com";
00023 $mail->Password = "yourpassword";
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
00033 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
00034 $mail->WordWrap = 50;
00035
00036 $mail->MsgHTML($body);
00037
00038 $mail->AddAddress("whoto@otherdomain.com", "John Doe");
00039
00040 $mail->AddAttachment("images/phpmailer.gif");
00041
00042 $mail->IsHTML(true);
00043
00044 if(!$mail->Send()) {
00045 echo "Mailer Error: " . $mail->ErrorInfo;
00046 } else {
00047 echo "Message sent!";
00048 }
00049
00050 ?>