Maison >développement back-end >tutoriel php > 在本机用phpmailer发送邮件有关问题
在本机用phpmailer发送邮件问题
我在本机上用的WampServer Version 2.1版本作为php服务器,来测试phpmailer发送邮件。我下载了最新的class.phpmailer.php和class.smtp.php文件,新建了个php文件phpmail.php来测试发送邮件功能,代码如下:
require_once('class.phpmailer.php');
include("class.smtp.php");
$mail = new PHPMailer(); //建立邮件发送类
$address = $_POST['address'];
$mail->SMTPDebug=true ;
$mail->IsSMTP(); // 使用SMTP方式发送
$mail->CharSet = "UTF-8"; //chinese;
$mail->Host = "smtp.163.com"; // 局smtp服务器
$mail->SMTPAuth = true; // 启用SMTP验证功能
$mail->Username = "cnmhg168"; // 用户名(请填写完整的email地址)
$mail->Password = "******"; // 密码
$mail->From = "cnmhg168@163.com"; //邮件发送者email地址
$mail->FromName = "化工网";
$mail->AddAddress("mysimpledesign@163.com", "tttt");//收件人地址
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件
$mail->IsHTML(true); // set email format to HTML //是否使用HTML格式
$mail->Subject = "PHPMailer测试邮件"; //邮件标题
$mail->Body = "Hello,这是测试邮件,百度"; //邮件内容
$mail->AltBody = "from 火星"; //附加信息,可以省略
//$mail->SMTPDebug;
if(!$mail->Send())
{
echo "邮件发送失败.
";
echo "错误原因: " . $mail->ErrorInfo;
exit;
}
echo "邮件发送成功";
?>
用户名和密码没问题,但是提示如下错误信息,不知道哪里有问题,求大家给解决下?
( ! ) Notice: Undefined index: address in D:\wamp\www\PHPMailer\phpmail.php on line 6
Call Stack
# Time Memory Function Location
1 0.0041 373128 {main}( ) ..\phpmail.php:0
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 163.com Anti-spam GT for Coremail System (163com[20121016]) "
SMTP -> get_lines(): $data is "220 163.com Anti-spam GT for Coremail System (163com[20121016]) "
SMTP -> FROM SERVER:220 163.com Anti-spam GT for Coremail System (163com[20121016])
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-mail "
SMTP -> get_lines(): $data is "250-mail "
SMTP -> get_lines(): $data was "250-mail "
SMTP -> get_lines(): $str is "250-PIPELINING "
SMTP -> get_lines(): $data is "250-mail 250-PIPELINING "
SMTP -> get_lines(): $data was "250-mail 250-PIPELINING "
SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN "
SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN "
SMTP -> get_lines(): $data was "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN "
SMTP -> get_lines(): $str is "250-AUTH=LOGIN PLAIN "
SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN "