时间:2021-07-01 10:21:17 帮助过:54人阅读
//phpmailer类require_once("./plugin/phpmailer/class.phpmailer.php");require_once("./plugin/phpmailer/class.smtp.php");//自己写的functionfunction SendMailToClient($client){ $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; // 设置为安全验证方式 $mail->Host = "smtp.qq.com"; // SMTP服务器地址 $mail->Username = "[email protected]"; // 登录用户名 $mail->Password = "psw"; // 登录密码 $mail->From = "[email protected]"; // 发件人地址([email protected]) $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."; echo "Mailer Error: " . $mail->ErrorInfo; return FALSE; } return TRUE;}//方法调用$client = "[email protected]";SendMailToClient($client);