php發(fā)送郵件函數(shù)mail 教程
來源:程序員人生 發(fā)布時(shí)間:2014-04-21 15:24:06 閱讀次數(shù):3022次
好了下面我們來看看php發(fā)送郵件函數(shù)mail 教程,如果要使用mail函數(shù)能夠正常使用我們還得配置php.ini里面的參數(shù)哦.
- <?php
-
- $boundary = uniqid( "" );
-
- $header = "From: $fromnContent-type: multipart/mixed;
- boundary="$boundary"nX-Mailer:PHPnX-Priority:3";
-
- $mimetype = mime_content_type('test.zip')
-
- $attach = 'test.zip'
-
- $fp = fopen($attach, "r");
- $content = fread($fp, filesize($attach));
- $content = chunk_split( base64_encode($content) );
-
- $body ="
- --$boundary
- Content-type: text/plain; charset=iso-8859-1
- Content-transfer-encoding: 8bit
- $message
- --$boundary
- Content-Type: $mimeType; name=$filename
- Content-Disposition: attachment; filename=$filename
- Content-Transfer-Encoding: base64
- $content
- --$boundary--";
-
- mail( $to, $subject, $body, $header );
- ?>
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)