SMTPDebug = 1; $mail->isSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->Port = 25; // set the SMTP port $mail->Host = "SMTP主机"; // SMTP server $mail->Username = "邮件帐户"; // SMTP account username $mail->Password = "邮件密码"; // SMTP account password $mail->setFrom('同邮件帐户', 'First Last'); $mail->addAddress('发送邮件到这个地址', 'John Doe'); $mail->Subject = 'testsubject'; $mail->Body = "test mail body"; $mail->send(); echo "Message sent!"; } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! }