php發送郵件

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   使用   io   ar   for   

發送郵件的類:

<?php/** * mail of class * * @author mrlenon */class Mailer {    function sendEmail($address, $name, $subject, $body) {        require(‘class.phpmailer.php‘);        $mail = new PHPMailer(); //建立郵件發送類        $mail->CharSet = "UTF-8"; //設定郵件編碼,預設ISO-8859-1,如果發中文此項必須設定,否則亂碼        $mail->IsSMTP(); // 使用SMTP方式發送        $mail->Host = "mail.hostuc.net"; // 您的企業郵局網域名稱        $mail->SMTPAuth = true; // 啟用SMTP驗證功能        $mail->Username = "[email protected]"; // 信箱使用者名(請填寫完整的email地址)        $mail->Password = "xx"; // 郵箱密碼        $mail->Port = 25; //連接埠        $mail->From = "[email protected]"; //郵件寄件者email地址        $mail->FromName = "xx"; //寄件者名稱        $mail->AddAddress($address, $name); //收件者地址,可以替換成任何想要內送郵件的email信箱,格式是AddAddress("收件者email","收件者姓名")        //$mail->AddReplyTo("", "");//抄送        //$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件        $mail->IsHTML(true); // set email format to HTML //是否使用HTML格式        $mail->Subject = $subject; //郵件標題        $mail->Body = $body; //郵件內容        //$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加資訊,可以省略        if ($mail->Send()) {            return 1;        } else {            return 0;        }    }}

代碼下載: http://files.cnblogs.com/MrLenon/mail.rar

php發送郵件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.