利用php中mail函數發送HTML郵件執行個體_PHP教程

來源:互聯網
上載者:User
在php中內建了郵箱發送函數mail()我們可以直接使用此函數進行郵件發送,下面我來介紹一些常用的郵箱發送執行個體,最簡單的就是mail函數了。

代碼如下 複製代碼

function send_mail($from, $to, $subject, $message)
{
if ($from == "")
{
$from = '回憶未來 ';//寄件者地址
}
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=gb2312' . "rn";
$headers .= 'From: ' . $from . "rn";
mail($to, $subject, $message, $headers);
}
?>

提示

要使用的程式是由 php.ini 檔案中的配置設定定義的,郵件函數的行為受 php.ini 的影響,我們必須先配置才行。

名稱 預設 描述 可更改

SMTP "localhost" Windows 專用:SMTP 伺服器的 DNS 名稱或 IP 位址。 PHP_INI_ALL
smtp_port "25" Windows 專用:SMTP 段口號。自 PHP 4.3 起可用。 PHP_INI_ALL
sendmail_from NULL Windows 專用:規定從 PHP 發送的郵件中使用的 "from" 地址。PHP_INI_ALL
sendmail_path NULL Unix 系統專用:規定sendmail 程式的路徑(通常 /usr/sbin/sendmail 或

/usr/lib/sendmail) PHP_INI_SYSTEM


http://www.bkjia.com/PHPjc/445294.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445294.htmlTechArticle在php中內建了郵箱發送函數mail()我們可以直接使用此函數進行郵件發送,下面我來介紹一些常用的郵箱發送執行個體,最簡單的就是mail函數了。...

  • 聯繫我們

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