1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Swaks でファイルを添付する方法【v20240103.0】

Posted at

結論

  • --attachment @filename のようにファイル名の前に@を加える。

  • 以前のバージョンでは@は必要ないですが、v20240103.0 から@が必要になりました。

経緯

ファイルを添付して送る際に@を抜いた状態で送信したところ、ファイル名のみBase64にて暗号化される現象に悩まされました。

ファイル添付メール送信テスト(失敗例)

$ swaks -t you@example.com --from me@example.com -au me@example.com --attach swakstest.txt --server 192.0.2.1 --body body.txt --header "Subject: Mailtest"

(省略)

 -> ------=_MIME_BOUNDARY_000_168599
 -> Content-Type: application/octet-stream
 -> Content-Disposition: attachment
 -> Content-Transfer-Encoding: BASE64
 -> 
 -> c3dha3N0ZXN0LnR4dA==   # ファイル名「swakstest.txt」がBase64に暗号化
 -> 
 -> ------=_MIME_BOUNDARY_000_168599--

ファイル添付メール送信テスト(成功例)

$ swaks -t you@example.com --from me@example.com -au me@example.com --attach @swakstest.txt --server 192.0.2.1 --body body.txt --header "Subject: Mailtest"

(省略)

 -> ------=_MIME_BOUNDARY_000_175923
 -> Content-Type: application/octet-stream; name="swakstest.txt"
 -> Content-Description: swakstest.txt
 -> Content-Disposition: attachment; filename="swakstest.txt"
 -> Content-Transfer-Encoding: BASE64
 -> 
 -> 44GT44KM44Gvc3dha3Pjga7jg4bjgrnjg4jjgafjgZnjgIIK # ファイルの中身がBase64に暗号化されました!
 -> 
 -> ------=_MIME_BOUNDARY_000_175923--

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?