欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

利用php怎么發(fā)送帶附件的郵件-創(chuàng)新互聯(lián)

這篇文章給大家介紹利用php怎么發(fā)送帶附件的郵件,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

創(chuàng)新互聯(lián)公司專(zhuān)注于漾濞網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供漾濞營(yíng)銷(xiāo)型網(wǎng)站建設(shè),漾濞網(wǎng)站制作、漾濞網(wǎng)頁(yè)設(shè)計(jì)、漾濞網(wǎng)站官網(wǎng)定制、微信小程序定制開(kāi)發(fā)服務(wù),打造漾濞網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供漾濞網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。
<html>
 <head>
 <title>帶附件的郵件發(fā)送</title>
 </head>
 <body> 
 <form method="post" name="form1" action="sendmail.php" ENCTYPE="multipart/form-data"> 
  <table> 
  <tr>
   <td>發(fā)送人:</td> 
   <td><input type="text" name="from"></td> 
  </tr> 
  <tr>
   <td>收件人:</td> 
   <td><input type="text" name="to"></td> 
  </tr> 
  <tr>
   <td>郵件主題:</td> 
   <td><input type="text" name="subject"></td> 
  </tr> 
  <tr>
   <td>郵件內(nèi)容:</td> 
   <td><textarea name="body"></textarea></td> 
  </tr> 
  <tr>
   <td>附件上傳:</td> 
   <td><input type="file" name="upload_file"></td> 
  </tr> 
  <tr> 
   <td span=2>
   <input type="submit" value="提交"> 
   <input type="reset" value="重置"> 
   </td> 
  </tr> 
  </table> 
 </form> 
 </body> 
</html>

sendmail.php文件代碼:

<?php  
//獲得表單信息 
$from = $_POST['from']; 
$to = $_POST['to'];  
$subject = $_POST['subject'];  
$body = $_POST['body'];  
// 定義分界線(xiàn)  
$boundary = "345894369383"; //分界線(xiàn)是一串無(wú)規(guī)律的字符 
//設(shè)置header 
$header = "Content-type: multipart/mixed; boundary= $boundary/r/n";  
$header .= "From:$from/r/n";  
//獲得上傳文件的文件內(nèi)容 
$file = $_FILES['upload_file']['tmp_name'];  
//確定上傳文件的MIME類(lèi)型  
$mimeType = $_FILES['upload_file']['type'];  
//獲得上傳文件的文件名  
$fileName = $_FILES['upload_file']['name'];  
//讀取上傳文件  
$fp = fopen($file, "r"); //打開(kāi)文件 
$read = fread($fp, filesize($file)); //讀入文件 
$read = base64_encode($read); //base64編碼  
$read = chunk_split($read); //切割字符串 
//建立郵件的主體,分為郵件內(nèi)容和附件內(nèi)容兩部分 
$body = "--$boundary  
Content-type: text/plain; charset=iso-8859-1  
Content-transfer-encoding: 8bit  
$body  
--$boundary  
Content-type: $mimeType; name=$fileName  
Content-disposition: attachment; filename=$fileName  
Content-transfer-encoding: base64  
$read  
--$boundary--";  
//發(fā)送郵件 并輸出是否發(fā)送成功的信息 
if(mail($to, $subject,$body,$header))  
{ 
  echo "信件發(fā)送成功";  
} 
else  
{ 
  echo "信件發(fā)送失敗";  
} 
?>

關(guān)于利用php怎么發(fā)送帶附件的郵件就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

網(wǎng)站標(biāo)題:利用php怎么發(fā)送帶附件的郵件-創(chuàng)新互聯(lián)
文章分享:http://www.chinadenli.net/article2/dchpic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作建站公司Google網(wǎng)站排名面包屑導(dǎo)航搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化