phpmailer

phpmailer在阿里云服务器发送邮件失败,中文乱码

怎甘沉沦 提交于 2020-03-11 13:46:47
我的环境是:apache+mysql+php 首先查看是否开启了socket与openssl扩展 如果没有那就找到php.ini文件并打开,开启这这个扩展 将 extension=php_openssl.dll 这个句代码前的“;”去掉 php_sockets.dll php_openssl.dll 发送邮件的代码中确保有这两句: $mail->SMTPSecure = 'ssl'; //设置使用ssl加密方式登录鉴权 $mail->Port = 465; //设置ssl连接smtp服务器的远程服务器端口号 465 给防火墙添加465端口的访问权限 之前我在本地测试一直正常,换上阿里云服务器之后邮件发送失败 是因为阿里云默认没有开启465端口的访问权限 服务器开启465安全组,最新的阿里云ECS可以直接在安全策略中配置 阿里云管理后台->云服务器->网络和安全->安全组->自行配置 完成后重启php和服务器 已经可以成功接收到邮件了。 补充一个小问题,我用alert弹出的中文显示乱码,本地测试是Ok的 这是原来的代码: exit("<script charset='UTF-8'>alert(\"留言成功!\");location.href='".$_SERVER["HTTP_REFERER"]."'</script>"); 然后改成了下面这句就不再乱码了 echo '<html>

添加邮件注册功能

穿精又带淫゛_ 提交于 2020-03-10 13:32:58
1 Test.php index 方法 $subject='验证码'; $code = mt_rand(100000,999999); $body='您的验证码是:'.$code; $email = ['XXXXXXX@163.com','XXXXXXX@qq.com','XXXXXX@qq.com']; $toemail=$email[0]; //$toemail='644034245@qq.com'; $name="ZZZZ"; $res = send_mail($toemail,$name,$subject,$body,$attachment = null); var_dump($res); if($res === true){ //记录邮件验证码 session('emailCode',$code); $msg=['status'=>1,'msg'=>'发送成功']; return json($msg); }else{ $msg=['status'=>-1,'msg'=>'发送失败']; return json($msg); } exit; 2 在 common.php文件 添加 send_mail() use phpmailer\PHPMailer; //发送邮件 function send_mail($toemail, $name, $subject = '',

PHPMailer not running with Xampp on Windows10

可紊 提交于 2020-03-05 04:24:08
问题 my problem is that PHPMailer (PHPMailer-master 6.0.3 to be exact) does not deliver emails when I run it with Xampp and Windows10. (I found a lot of comments on that subject but none of them led to a solution.) The following code runs fine on a remote server: <?php // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // 'PHPMailer' here actually is the

服务器环境(插件)搭建

て烟熏妆下的殇ゞ 提交于 2020-02-27 01:29:32
PHP开发工具: neteasecloudmusic ,phpstorm,postman,rdm,navicat for mysql,iterm,google chrome, dingtalk,wechat, youdao 正式和测试区别开有:域名,数据库,代码仓库分支(正式master,测试dev). 主流环境(插件):最笨就用宝塔面板,安全考虑使用以下: Grafana接口监控 https://www.jianshu.com/p/3527f48165d7 Jenkins代码部署 Sentry日志查看 GitLab代码仓库 Jumpserver堡垒机:在线文件管理,命令执行 sql审计平台 接口文档:swagger, CMIT 石墨在线办公文档 项目分工流程:禅道,钉钉蚂蚁分工,worktile 产品原型图,UI:蓝湖 PHP常用插件包:composter https://packagist.org/ https://www.phpcomposer.com/ topthink/framework ThinkPHP 核心框架库 rmccue/requests 用PHP编写的HTTP库 predis/predis Redis- Predis 扩展 lcobucci/jwt JWT 创建 Token phpmailer/phpmailer 实现PHP发邮件功能 endroid/qr

使用GMail SMTP服务器从PHP页面发送电子邮件

僤鯓⒐⒋嵵緔 提交于 2020-02-26 11:10:25
我正在尝试从PHP页面通过GMail的SMTP服务器发送电子邮件,但出现此错误: 身份验证失败[SMTP:SMTP服务器不支持身份验证(代码:250,响应:mx.google.com,为您提供服务,[98.117.99.235]大小为35651584 8位MIME STARTTLS ENHANCEDSTATUSCODES PIPELINING)] 有人可以帮忙吗? 这是我的代码: <?php require_once "Mail.php"; $from = "Sandra Sender <sender@example.com>"; $to = "Ramona Recipient <ramona@microsoft.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "smtp.gmail.com"; $port = "587"; $username = "testtest@gmail.com"; $password = "testtest"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' =

如何将整个MySQL数据库字符集和排序规则转换为UTF-8?

家住魔仙堡 提交于 2020-02-25 19:04:35
如何将整个MySQL数据库字符集转换为UTF-8并将排序规则转换为UTF-8? #1楼 在命令行外壳上 如果您是命令行外壳程序之一,则可以非常快速地执行此操作。 只需填写“ dbname”:D DB="dbname" ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;' mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names \ | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) \ | mysql "$DB" 一线可轻松复制/粘贴 DB="dbname"; ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'; mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8

PHPMailer loads a while, then gives 500 - Internal server error

浪子不回头ぞ 提交于 2020-02-21 10:57:30
问题 I am trying to setup a php page to automatically send a verification email. I would like to use the gmail smtp servers, and everywhere I've looked suggests to use PHPMailer. I installed it and used the following example code: ini_set('display_errors', 1); error_reporting(E_ALL); require_once ("incl\PHPMailer\PHPMailerAutoload.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->SMTPSecure = "tls"; $mail->Host = "smtp.gmail.com"; $mail->Port = 587; $mail->Username =

PHPMailer loads a while, then gives 500 - Internal server error

妖精的绣舞 提交于 2020-02-21 10:57:29
问题 I am trying to setup a php page to automatically send a verification email. I would like to use the gmail smtp servers, and everywhere I've looked suggests to use PHPMailer. I installed it and used the following example code: ini_set('display_errors', 1); error_reporting(E_ALL); require_once ("incl\PHPMailer\PHPMailerAutoload.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->SMTPSecure = "tls"; $mail->Host = "smtp.gmail.com"; $mail->Port = 587; $mail->Username =

PHP利用qq邮箱发邮件

折月煮酒 提交于 2020-02-16 10:03:10
1.下载代码源码 https://github.com/PHPMailer/PHPMailer 2.在代码中放入composer.phar 安装phpmailer/phpmailer 3.到qq邮箱配置 开启SMTP服务 4.记住授权码 4.下载好phpmailer 后只需要几个重要的文件即可,其余的都可以删除 class.phpmailer.php class.pos3.php class.smtp.php 4.将这三个文件重新放置 有用的只有圈起来的三部分 5.编写发送邮件代码,封装在functions.php <?php /** * Created by PhpStorm. * User: xym * Date: 2018/7/27 * Time: 下午3:28 */ /*发送邮件方法 *@param $to: 接收者 $title: 标题 $content: 邮件内容 *@return bool true: 发送成功 false: 发送失败 */ function sendMail($to, $title, $content) { //引入PHPMailer的核心文件 使用require_once包含避免出现PHPMailer类重复定义的警告 require_once("phpmailer/class.phpmailer.php"); require_once(