第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過 php 郵件發(fā)送時無法為 ics 文件設(shè)置名稱

通過 php 郵件發(fā)送時無法為 ics 文件設(shè)置名稱

PHP
千萬里不及你 2023-09-22 14:43:30
當(dāng)我使用 mail() 函數(shù)發(fā)送文件時,我試圖設(shè)置文件的名稱,我發(fā)送了它,但在 gmail 中我收到的是沒有擴(kuò)展名的無名文件。有人可以幫我嗎?<?php$temp = tmpfile();fwrite($temp, $ical);rewind($temp);$to_email = 'test@gmail.com';$subject = 'Testing PHP Mail';$message = 'Hola caracola';$from_email = 'test@test.com';$path = stream_get_meta_data($temp)['uri'];$num = md5(time());$headers = "MIME-Version: 1.0\r\n"; // Defining the MIME version $headers .= "From:".$from_email."\r\n"; // Sender Email $headers .= "Reply-To: ".$from_email."\r\n"; // Email addrress to reach back $headers .= "Content-Type: multipart/mixed;\r\n"; // Defining Content-Type $body ="Content-Type: text/calendar; name=invite.ics\r\n"; $body .="Content-Disposition: attachment; filename=\"invite.ics\"\r\n";  $body .= $content; // Attaching the encoded file with email     mail($to_email,$subject,$body,$headers);    fclose($temp);} ?>謝謝
查看完整描述

1 回答

?
牛魔王的故事

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個贊

我剛剛做到了,我粘貼了下面的代碼,問題是 php 將新策略應(yīng)用于新行標(biāo)題,所以我只需更改一些代碼即可避免此限制并解決問題:


<?php

$temp = tmpfile();


fwrite($temp, $ical);

rewind($temp);

$to_email = 'test@gmail.com';

$subject = 'Testing PHP Mail';

$message = 'Hello';

$from_email = 'test@test.com';

$path = stream_get_meta_data($temp)['uri'];


$eol = PHP_EOL;


$filename = "invite.ics";

$mailto = $to_email;

$from_mail = $from_email;

$from_name = "Events";

$replyto = $from_email;


$file = $path;

$file_size = filesize($path);

$handle = fopen($file, "r");

$content = fread($handle, $file_size);

fclose($handle);

$content = chunk_split(base64_encode($content));

$uid = md5(uniqid(time()));

$header = "From: ".$from_name." <".$from_mail.">".$eol;

$header .= "Reply-To: ".$replyto.$eol;

$header .= "MIME-Version: 1.0\r\n";

$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"";


$message = "--".$uid.$eol;

$message .= "Content-Type: application/pdf; name=\"".$filename."\"".$eol; // use different content types here

$message .= "Content-Transfer-Encoding: base64".$eol;

$message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol;

$message .= $content.$eol;

$message .= "--".$uid."--";


mail($mailto, $subject, $message, $header);

    

fclose($temp);

?>


查看完整回答
反對 回復(fù) 2023-09-22
  • 1 回答
  • 0 關(guān)注
  • 87 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號