Copy Code code as follows:
<TITLE>PHPMAILER-SMTP (Gmail) Basic test</title>
<body>
<?php
Error_reporting (E_all);
Error_reporting (e_strict);
Date_default_timezone_set (' America/toronto ');
Require_once ('.. /class.phpmailer.php ');
Include ("class.smtp.php"); Optional, gets called from within class.phpmailer.php if not already loaded
$mail = new Phpmailer ();
$body = file_get_contents (' contents.html ');
$body = eregi_replace ("[\]", ", $body);
$mail->issmtp (); Telling the class to use SMTP
$mail->host = "mail.gmail.com"; SMTP Server
$mail->smtpdebug = 2; Enables SMTP debug information (for testing)
1 = errors and messages
2 = messages Only
$mail->smtpauth = true; Enable SMTP Authentication
$mail->smtpsecure = "SSL"; Sets the prefix to the Servier
$mail->host = "smtp.gmail.com"; Sets GMAIL as the SMTP server
$mail->port = 465; Set the SMTP port for the GMAIL server
$mail->username = "* * * @gmail. com"; GMAIL username
$mail->password = "* * *"; GMAIL Password
$mail->setfrom (' * * * @gmail. com ', ' the ' last ');
$mail->addreplyto ("* * @gmail. com", "the Last");
$mail->subject = "Phpmailer Test Subject via SMTP (Gmail), basic";
$mail->altbody = "To view", compatible email viewer! with an HTML; Optional, comment out and test
$mail->msghtml ($body);
$address = "* * * @gmail. com";
$mail->addaddress ($address, "John Doe");
$mail->addattachment ("Images/phpmailer.gif"); Attachment
$mail->addattachment ("Images/phpmailer_mini.gif"); Attachment
if (! $mail->send ()) {
echo "Mailer Error:". $mail->errorinfo;
} else {
echo "Message sent!";
}
?>
</body>