<?php
Require ("class.phpmailer.php");
Require ("class.smtp.php");
Here is an example:
$mail = new Phpmailer (); Set up a mail sending class
$mail->issmtp (); Send using SMTP mode
$mail->host = "smtp.163.com"; Your enterprise Post office domain name
$mail->smtpauth = true;
$mail->username = "[email protected]";
$mail->password = "xxx";
$mail->from = "[email protected]";
$mail->fromname = "Your name";
$mail->addaddress ("[Email protected]", "tt"); The recipient address can be replaced with any email message you want to receive, in the form addaddress ("Recipient Email", "Recipient Name")
$mail->addreplyto ("," "");
$mail->addattachment ("/var/tmp/file.tar.gz"); Add an attachment
$mail->ishtml (TRUE); Set email format to HTML//whether HTML is used
$mail->subject = "phpmailer test mail"; Message header
$mail->body = "Hello, this is Test mail"; Message content
$mail->altbody = "The body in plain text for non-html mail clients"; Additional information, you can omit
if (! $mail->send ()) {
echo "message failed to send. <p> ";
echo "Error Reason:". $mail->errorinfo;
Exit
}
echo "Mail sent successfully";
?>
php Send mail code