作者LHD.bbs@LHD.twbbs.org (君シ笑ゲサゆギゆプ) 看板: itoc
標題Re: [問題] 關於打包資料
時間遊民之家 (2007/04/09 Mon 00:08:51)
※ 引述《itoc.bbs@cpu.tfcis.org (核心動力)》之銘言:
> ※ 引述《hpo14.bbs@ntust.org (陌生)》之銘言:
> > 不管是用 [Content-Type: application/x-gzip] or [application/binary]
> > 打包寄到學校的資料,都會被網頁用明碼打開,不會是附檔的形式
> 現在新的 mail.c:bsmtp() 不用 application/x-gzip
> 而改用 application/x-compressed,並加了 filename
> 你再試試看好了
這樣還是不方便~
因為是用 uuencode,我以前試過似乎只有 Outlook Express 能自動辨識
像 gmail 或 mutt 取出來後都要再用 uudecode 才能正確解開
而我之前是給 uuencode -m 讓他直接用 base64 編碼,並在 header 中說明是 base64
這樣不管是 gmail 還是 mutt 都能直接取出立即使用~
配合這次 itoc 改的 code 合併如下:
: bsmtp()
/* itoc.030323: mail 輸出 RFC 2045 */
fprintf(fw, "Mime-Version: 1.0\r\n"
"Content-Type: %s; charset="MYCHARSET"\r\n"
! "Content-Transfer-Encoding: %s\r\n",
method & MQ_ATTACH ? "application/x-compressed" : "text/plain",
+ method & MQ_ATTACH ? "base64" : "8bit");
if (method & MQ_ATTACH)
fprintf(fw, "Content-Disposition: attachment; filename=%s.tgz\r\n",
cuser.userid);
fprintf(fw, "X-Sender: %s (%s)\r\n"
"X-Disclaimer: [%s] 對本信內容恕不負責\r\n\r\n",
cuser.userid, cuser.username, str_site);
...
/* ------------------------------------------------- */
/* begin of mail body */
/* ------------------------------------------------- */
if (fp = fopen(fpath, "r"))
{
char *ptr;
str = buf;
*str++ = '.';
+ if (method & MQ_ATTACH) /* LHD.061222: 去掉開頭 begin 那行 */
+ fgets(str, sizeof(buf) - 3, fp);
while (fgets(str, sizeof(buf) - 3, fp))
...
: do_forward()
!sprintf(cmd, "tar cfz - %s | uuencode -m %s.tgz > tmp/%s.tgz", fpath, userid,
userid);
--
▃▄▅▆▇▅▄▃▂▁ ◣ ◢ █◣◢█ ● bbs.cis95.net
▇▅▄▂▁ˍ▃▅▆ 居無定所的雲 ◥█◤ ◤◥ █◥◤█ ▲ █▇◣ 遊民之家
飄自 bbs.cs.nctu.edu.tw █ ◣◢ █ █ █ █ █‧twbbs‧org