🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
先附上PHPMailer下载地址:https://github.com/VisionZheng/PHPMailer 使用方法: ```php <?php $rootPath = dirname(__FILE__); require $rootPath.'/PHPMailer/PHPMailerAutoload.php'; $mail = new PHPMailer; // 调试模式,可以看到哪里出现错误 //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.aliyun.com'; // Specify main and backup SMTP servers // 是否需要验证 $mail->SMTPAuth = true; // Enable SMTP authentication // 邮件内容编码 $mail->CharSet = 'UTF-8'; $mail->Username = 'vision@aliyun.com'; // SMTP username $mail->Password = '********'; // SMTP password // $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 25; // TCP port to connect to // 设置发件人 $mail->setFrom('visionz@aliyun.com', 'visionz'); // 设置收件人,可以有多个,多个在同样的加 $mail->addAddress('1092161320@qq.com', 'asdfasdfasf'); // Add a recipient // $mail->addAddress('ellen@example.com'); // Name is optional // 回复给哪个邮箱 $mail->addReplyTo('visionz@aliyun.com', 'visionz'); // 抄送给谁 // $mail->addCC('cc@example.com'); // $mail->addBCC('bcc@example.com'); // 附件 // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name // 正文是否有加HTML标签 $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subjectdfdfdfd'; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; // 直接发送HTML文件里的内容 // $mail->msgHTML(file_get_contents($rootPath."/sendmail.html")); // 没有带HTML的内容 // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; } ```