phpMailer在thinkPHP架構中郵件發送

來源:互聯網
上載者:User

標籤:

資源: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;  }?>

 

phpMailer在thinkPHP架構中郵件發送

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.