zoukankan      html  css  js  c++  java
  • phpMailer在thinkPHP框架中邮件发送

    资源下载地址:http://pan.baidu.com/s/1c0kAoeO
    提取码:ry5v
    关键代码:application/Common/Common/funciton.php 
    
    <?php
      import('Com.Email.PHPMailer');
      import('Com.Email.SMTP');
    
      function send_mail($title, $content, $from, $to, $chart = 'utf-8', $attachment = '') {
        $mail = new PHPMailer ();
        $mail->CharSet = $chart; // 设置采用utf-8中文编码
        $mail->IsSMTP ( 'smtp' ); // 设置采用SMTP方式发送邮件
        $mail->Host = "smtp.126.com"; // 设置邮件服务器的地址
        $mail->Port = 25; // 设置邮件服务器的端口,默认为25
        $mail->From = "********@126.com"; // 设置发件人的邮箱地址
        $mail->FromName = "******"; // 设置发件人的姓名
        $mail->SMTPAuth = true; // 设置SMTP是否需要密码验证,true表示需要
        $mail->Username = "*********.com"; // 设置发送邮件的邮箱
        $mail->Password = "********"; // 设置邮箱的密码
        $mail->Subject = $title; // 设置邮件的标题
        $mail->AltBody = "text/html"; // optional, comment out and test
        $mail->Body = $content; // 设置邮件内容
        $mail->IsHTML ( true ); // 设置内容是否为html类型
        $mail->WordWrap = 50; // 设置每行的字符数
        $mail->AddReplyTo ( "地址", "名字" ); // 设置回复的收件人的地址
        $mail->AddAddress ( $to, "" ); // 设置收件的地址
        if ($attachment != '') {
          $mail->AddAttachment ( $attachment, $attachment );
        }
        if ($mail->Send ()) {
          $status = "$to" . '&nbsp;&nbsp;已投送成功<br />';
        } else {
          $status = "$to" . '&nbsp;&nbsp;发送邮件失败<br />';
        }
        return $array;
      }
    
    ?>
  • 相关阅读:
    URAL 2080 莫队
    Codeforces Round #361 (Div. 2) C D
    UVALive 7297 bfs
    UVALive 7472
    HDU 5773 最长上升子序列
    递归求解最大值和最小值
    数字方阵旋转问题
    实现循环队列的各种基本运算
    实现顺序栈的各种基本运算
    使用两个栈来实现队列
  • 原文地址:https://www.cnblogs.com/qhorse/p/4785331.html
Copyright © 2011-2022 走看看