The following is the test File: & lt ;? Phprequire (& quot; class. phpmailer. php & quot;); // the downloaded file must be placed in the directory where the file is located $ mailnewPHPMailer (); // create an email sending class $ address & quot; email address of the recipient & quot; // email address of the recipient...
The following is the test file:
Require ("class. phpmailer. php"); // the downloaded file must be in the directory where the file is located.
$ Mail = new PHPMailer (); // Create a mail sending class
$ Address = "email address of the recipient"; // email address of the recipient
$ Mail-> IsSMTP (); // send using SMTP
$ Mail-> Host = "smtp.qq.com"; // your enterprise Post Office domain name
$ Mail-> SMTPAuth = true; // enable SMTP verification
// The following $ mail-> Username, $ mail-> Password, $ mail-> From is required
$ Mail-> Username = "address of the user who sent the email"; // address of the user who sent the email
$ Mail-> Password = "Password of the user who sent the email"; // Password of the user who sent the email
$ Mail-> Port = 25;
$ Mail-> From = "email address of the user who sent the mail"; // email address of the mail sender
// $ Mail-> FromName = "10-php ";
$ Mail-> AddAddress ("$ address", 'recipient names can be dispensable '); // recipient address, which can be replaced with any email box to receive emails, the format is AddAddress ("recipient email", "recipient name ")
// $ Mail-> AddReplyTo ("", ""); www.2cto.com
// $ Mail-> AddAttachment ("/var/tmp/file.tar.gz"); // add an attachment
// $ Mail-> IsHTML (true); // set email format to HTML // whether HTML format is used
$ Mail-> Subject = "PHPMailer test mail"; // mail title
$ Mail-> Body = "Hello, this is the test mail"; // The mail content
$ Mail-> AltBody = "This is the body in plain text for non-HTML mail clients"; // additional information, which can be omitted
If (! $ Mail-> Send ())
{
Echo "failed to send the email.
";
Echo "error cause:". $ mail-> ErrorInfo;
Exit;
}
Echo "email sent successfully ";