HTML代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>邮箱注册</title>
<link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">
</head> <body>
<form action="/home/login/peroper" method="post" style="width: 300px">
<div class="form-group">
<label for="name">对方邮箱</label>
<input type="text" class="form-control" name="email" id="name">
</div>
<div class="form-group">
<label for="name">标题</label>
<input type="text" class="form-control" name="title" id="name">
</div> <div class="form-group">
<label for="name">内容</label>
<input type="textarea" class="form-control" name="content" id="name">
</div> <button type="submit" class="btn btn-success">立即邀请</button> </form> </body>
</html>

控制器代码:

    public function peroper()
{
// 接受邮箱参数
$params = input();
$email = $params['email'];//接受对方邮箱号码
$title = $params['title'];//邮箱主题
$content = $params['content'];//邮箱内容
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//服务器配置
$mail->CharSet = "UTF-8"; //设定邮件编码
$mail->SMTPDebug = 0; // 调试模式输出
$mail->isSMTP(); // 使用SMTP
$mail->Host = 'smtp.qq.com'; // SMTP服务器
$mail->SMTPAuth = true; // 允许 SMTP 认证
$mail->Username = '910624858@qq.com'; // SMTP 用户名 即邮箱的用户名
$mail->Password = 'syqyafshccsabbhh'; // SMTP 密码 部分邮箱是授权码(例如163邮箱)
$mail->SMTPSecure = 'ssl'; // 允许 TLS 或者ssl协议
$mail->Port = 465; // 服务器端口 25 或者465 具体要看邮箱服务器支持
$mail->setFrom('910624858@qq.com', 'yanbing'); //发件人
$mail->addAddress($email); // 收件人
//$mail->addAddress('ellen@example.com'); // 可添加多个收件人
$mail->addReplyTo('910624858@qq.com', 'yanbing'); //回复的时候回复给哪个邮箱 建议和发件人一致
//$mail->addCC('cc@example.com'); //抄送
//$mail->addBCC('bcc@example.com'); //密送 //发送附件
// $mail->addAttachment('../xy.zip'); // 添加附件
// $mail->addAttachment('../thumb-1.jpg', 'new.jpg'); // 发送附件并且重命名
//Content
$mail->isHTML(true); // 是否以HTML文档格式发送 发送后客户端可直接显示对应HTML内容
$mail->Subject = $title . time();
$mail->Body = $content . date('Y-m-d H:i:s');
$mail->AltBody = '如果邮件客户端不支持HTML则显示此内容';
$mail->send();
echo '邮件发送成功'; } catch (Exception $e) {
echo '邀请失败: ', $mail->ErrorInfo;
} }

tp5实现邮件发送(无注释)的更多相关文章

  1. TP5实现邮件发送(PHP 利用QQ邮箱发送邮件「PHPMailer」)

    在 PHP 应用开发中,往往需要验证用户邮箱.发送消息通知,而使用 PHP 内置的 mail() 函数,则需要邮件系统的支持. 如果熟悉 IMAP/SMTP 协议,结合 Socket 功能就可以编写邮 ...

  2. tp5实现邮件发送

    项目中,用户修改密码,需要发送验证码到用户邮箱,于是就看了看,在此记录一下. 1.开启SMTP服务 测试用的是自己的qq邮箱,首先需要开启邮箱的SMTP服务,开启之后,要记得给你的授权码,授权码一定要 ...

  3. Tp5.0 PHPMailer邮件发送

    今天突然想起来邮件发送,就看了一下PHPmailer,其实这个用起来很简单,都是封装好的 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,把他放入TP5 ...

  4. TP5使用phpmailer实现邮件发送

    1.从github下载PHPMailer,在vendor目录中新建文件夹phpmailer,将压缩包中的class.phpmailer.php和class.smtp.php复制到phpmailer中, ...

  5. python 发送无附件邮件

    import smtplibimport tracebackfrom email.mime.text import MIMETextfrom config.config import *        ...

  6. 【Thinkphp 5】 整合邮箱类 phpmailer实现邮件发送

    第一步:下载phpmailer文件,主要用到的文件只有箭头指向的两个,thinkphp5中,把class.phpmailer.php改成了phpmailer.php 第二步: 将phpmailer文件 ...

  7. 测试开发【提测平台】分享11-Python实现邮件发送的两种方法实践

    微信搜索[大奇测试开],关注这个坚持分享测试开发干货的家伙. 按照开发安排,本篇本应该是关于提测页面的搜索和显示实现,怕相似内容疲劳,这期改下内容顺序,将邮件服务的相关的提前,在之前的产品需求和原型中 ...

  8. .NET开发邮件发送功能的全面教程(含邮件组件源码)

    今天,给大家分享的是如何在.NET平台中开发“邮件发送”功能.在网上搜的到的各种资料一般都介绍的比较简单,那今天我想比较细的整理介绍下: 1)         邮件基础理论知识 2)         ...

  9. 利用PHPMailer 来完成PHP的邮件发送 #转载自:大菜鸟在云端#

    利用PHPMailer 来完成PHP的邮件发送 1.首先是下载PHPMailer http://code.google.com/a/apache-extras.org/p/phpmailer/ 2.解 ...

随机推荐

  1. Visual Studio 中快速创建方法 Generate a method in Visual Studio

    2020-04-04 https://docs.microsoft.com/en-us/visualstudio/ide/reference/generate-method?view=vs-2019 ...

  2. Git远程仓库地址操作

    添加 git remote add test1_origin git@github.com:b84955189/test1.git test1_origin:远程地址名,这里是我自定的. git@gi ...

  3. Java 重写paint绘图

    感谢原文:https://zhidao.baidu.com/question/260060153.html 这个方法需要注意的地方不多,也就是重写时,先调用 super.paint(g) 方法 pai ...

  4. JVM收藏的文章

    JAVA 内存泄露详解(原因.例子及解决) https://blog.csdn.net/anxpp/article/details/51325838 JVM内存区域划分Eden Space.Survi ...

  5. 部署YUM仓库及NFS共享服务

    部署YUM仓库及NFS共享服务 目录 部署YUM仓库及NFS共享服务 一.YUM仓库服务 1. YUM概述 2. 部署YUM软件仓库 (1)准备安装源 ①YUM仓库的种类 ②RPM软件包的来源 ③构建 ...

  6. php使用CURL实现GET和POST方式请求

    CURL请求,支持GET和POST两种方式,默认为GET方式,如果传第二个参数则为POST方式请求,设置了超时时间,避免程序卡死. /** 使用curl方式实现get或post请求 @param $u ...

  7. 数据缓存Cache

    在MyBatis - 随笔分类 - 池塘里洗澡的鸭子 - 博客园 (cnblogs.com)中有关于Mybatis中Cache技术实现及应用介绍.Cache技术实现都是implements Cache ...

  8. 数据分析实际案例之:pandas在泰坦尼特号乘客数据中的使用

    目录 简介 泰坦尼特号乘客数据 使用pandas对数据进行分析 引入依赖包 读取和分析数据 图形化表示和矩阵转换 简介 1912年4月15日,号称永不沉没的泰坦尼克号因为和冰山相撞沉没了.因为没有足够 ...

  9. 已经安装的nginx增加额外配置步骤

    这里以安装第三方ngx_http_google_filter_module模块为例nginx的模块是需要重新编译nginx,而不是像apache一样配置文件引用.so1. 下载第三方扩展模块ngx_h ...

  10. flag_in_your_hand1

    给了两个 文件 index.html 和 一个js文件 ,考察js代码审计能力首先借助浏览器来运行js 程序.用浏览器打开index.html,分析 js 代码: 首先无论在 token 输入框中输入 ...