日期:2014-05-17 浏览次数:20542 次
//phpmailer类 require_once("./plugin/phpmailer/class.phpmailer.php"); require_once("./plugin/phpmailer/class.smtp.php"); //自己写的function function SendMailToClient($client){ $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; // 设置为安全验证方式 $mail->Host = "smtp.qq.com"; // SMTP服务器地址 $mail->Username = "xxxxxx@qq.com"; // 登录用户名 $mail->Password = "psw"; // 登录密码 $mail->From = "xxxxxx@qq.com"; // 发件人地址(username@163.com) $mail->FromName = "发件人名称"; $mail->WordWrap = 50; $mail->IsHTML(true); // 是否支持html邮件,true 或false $mail->AddAddress("$client"); //客户邮箱地址 $mail->Subject = "标题"; $mail->Body = "文本内容"; if(!$mail->Send()){ echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; return FALSE; } return TRUE; } //方法调用 $client = "client@mail.com"; SendMailToClient($client);