使用sendmail產生subject亂碼

2021-08-04 00:12:26 字數 703 閱讀 4379

首先,這個問題頭疼了我好多天,因為我一共使用sendmail同時傳送5封郵件,郵件的subject分別為【xx】***x總資料,【xx】******part1資料,【xx】***xpart2資料,【xx】***xpart3資料,【xx】***xpart4資料,其中有一些是有英文,有一些是有重複字串,最後導致的結果是一部分的郵件標題不亂嗎,一部分的亂碼,有時候修改郵件的內容,標題也會變得亂碼,我從shell的編碼格式,到輸出格式,到html的格式,都調整過,還是找不到原因,最後只有單測樣例,通過刪除郵件標題中的某個欄位來測試結果,發現果然成功,可能是subject的某些字串編碼結果造成了郵箱軟體輸出的類似於sql注入的效果,造成了亂碼。

我的測試方法是:

echo "******" |formail -i "***xx@***xx.com" -i "******@***x.com" -i "mime-version:1.0" -i "content-type:text/html;charset=utf-8" -i "subject:=?utf-8?b?`echo '【***】******x明細' |iconv -f 'utf-8' -t 'utf-8' |openssl enc -base64 `?=" | /usr/sbin/sendmail -oi ******x@***xx.com

大家在測試的時候可以一步一步的刪除subject中的字元來看是哪個字的亂碼。然後嘗試修改下。

SendMail 傳送測試 使用

extern c declspec dllimport dword setmailinfo char subject,char context,char filename extern c declspec dllimport dword setmaildest char mailname exte...

sendmail命令的使用

echo e subject a subject n nmessage text sendmail f my address recipient address 你同時也可以cat 1.txt sendmail f my address recipient address sed i 1isubje...

busybox中sendmail命令使用

1 busybox 只支援sendmail命令傳送郵件,暫不支援mail命令 mail呼叫sendmail命令傳送郵件 2 sendmail用法 cat mail.txt subject test cc to to 163.com from from 163.com 郵件格式頭和內容之間一定要有空行...