原文:
效果:
访问: test.php
马上,qq邮箱就收到邮件了。
代码如下:
IsSMTP(); $mail->CharSet='UTF-8'; //设置邮件的字符编码,这很重要,不然中文乱码 $mail->SMTPAuth = true; //开启认证 $mail->Port = 25; $mail->Host = "smtp.163.com"; $mail->Username = "username@163.com"; $mail->Password = "password";//$mail->IsSendmail(); //如果没有sendmail组件就注释掉,否则出现“Could not execute: /var/qmail/bin/sendmail ”的错误提示 $mail->AddReplyTo("username@163.com","mckee");//回复地址 $mail->From = "username@163.com"; $mail->FromName = "www.phpddt.com"; $to = "981883873@qq.com"; $mail->AddAddress($to); $mail->Subject = "phpmailer测试标题"; $mail->Body = "phpmail演示
这是php点点通(www.phpddt.com)对phpmailer的测试内容"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //当邮件不支持html时备用显示,可以省略 $mail->WordWrap = 80; // 设置每行字符串的长度//$mail->AddAttachment("f:/test.png"); //可以添加附件 $mail->IsHTML(true); $mail->Send(); echo '邮件已发送';} catch (phpmailerException $e) { echo "邮件发送失败:".$e->errorMessage();}?>