Instance require_once ('phpmailer/class. phpmailer. php '); // introduce the phpmailer file require_once ('phpmailer/class. smtp. php '); $ mail = new PHPMailer (); // instantiate the phpmailer class $ mail-> IsSMTP (); $ mail-> CharSet = 'utf-8 '; $ mail-> AddAddress (123@163.com); // recipient email $ mail-> Body = $ content; // sender content $ mail-> From = from@163.com; // sender email from@163.com $ mail-> FromName = "zjsupport"; // sender's name $ mail-> Subject = "title "; // mail title $ mail-> Host = "smtp.163.com"; // smtp server $ mail-> SMTPAuth = true; // enable the smtp service $ mail-> IsHTML (true ); // send the attachment $ mail-> AddAttachment (path, name); // path indicates the Save path of the attachment. name indicates the name of the attachment. // you can upload multiple attachments, exactly copy $ mail-> AddAttachment (path, name); Code on the line $ mail-> Username = "from@163.com"; // sender mailbox $ mail-> Password = "123456 "; // sender's email password if ($ mail-> Send () {// determines whether the email is successfully sent echo "success";} else {$ email_error = $ email_error. ";". $ val; // if the email address fails to be sent, the email address will be saved to the string.} if ($ email_error = "") {echo "email_success" ;}else {echo $ email_error ;}