<?php
Error_reporting (E_all);
Error_reporting (e_strict);
Date_default_timezone_set (' America/toronto ');
Date_default_timezone_set (Date_default_timezone_get ());
Include_once ('.. /class.phpmailer.php ');
Include ("class.smtp.php"); Optional, gets called from within class.phpmailer.php if not already loaded
$mail =new Phpmailer ();
$body = $mail->getfile (' contents.html ');
$body =eregi_replace ("[\]" ",", $body);
$mail->issmtp (); Telling the class to use SMTP
$mail->host = "smtp.126.com"; SMTP Server
$mail->port = 25; Set the SMTP port for the GMAIL server
$mail->smtpauth = true; Turn on SMTP authentication
$mail->username = "[email protected]"; SMTP username Note: Normal mail authentication does not need to add @ domain name
$mail->password = "Password"; SMTP Password
$mail->from = "[email protected]";
$mail->fromname = "name";
$mail->charset = "GB2312"; Specify the character set here!
$mail->encoding = "base64";
$mail->addaddress ("[Email protected]", "name"); Recipient's mailbox and name
$mail->addreplyto ("[Email protected]", "cgsir.com");
$mail->subject = "Phpmailer Test Subject via SMTP";
$mail->msghtml ($body);
$mail->addattachment ("Images/phpmailer.gif"); Attachment
if (! $mail->send ()) {
echo "Mailer Error:". $mail->errorinfo;
} else {
echo "Message sent!";
}
?>
Phpmailer sending mail with SMTP