邮件api接口文件在附件中
因为很多地方都可能用到发邮件技术,所以封装成方法方便其他地方调用
function send_mail($address, $subject, $content){ vendor('PhpMailer.PHPMailerAutoload'); $mail = new PHPMailer; $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->Username = 'xxxx@aliyun.com'; // SMTP username $mail->Password = 'xxxxx'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 1234; // TCP port to connect to $mail->setFrom('xxxx@aliyun.com', 'xxxx'); $mail->addAddress($address, 'Joe User'); // Add a recipient // $mail->addAddress('ellen@example.com'); // Name is optional // $mail->addReplyTo('info@example.com', 'Information'); // $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 $mail->isHTML(true); // Set email format to HTML $mail->CharSet='UTF-8'; $mail->Subject = $subject; $mail->Body = $content; // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if(!$mail->send()) { return false; } else { return true; } }
api接口文件路径放置: