Sample as below:
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.yourdomain.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->host = "mail.yourdomain.com"; Sets the SMTP server$mail->port = 26; Set the SMTP port for the GMAIL server$mail->username = "[email protected]"; SMTP account Username$mail->password = "YourPassword"; SMTP Account password$mAil->setfrom (' [email protected] ', ' first Last '), $mail->addreplyto ("[email protected]", "First Last "); $mail->subject =" Phpmailer Test Subject via SMTP, basic with Authentication "; $mail->altbody =" To view the message, please use an HTML compatible email viewer! "; Optional, comment out and test$mail->msghtml ($body); $address = "[email protected]"; $mail->addaddress ($ Address, "John Doe"); $mail->addattachment ("Images/phpmailer.gif"); Attachment$mail->addattachment ("Images/phpmailer_mini.gif"); Attachmentif (! $mail->send ()) {echo "Mailer Error:". $mail->errorinfo;} else {echo "Message sent!";}
Basic Example using SMTP (for Phpmailer v5.0.0 and up)