
sendmailに添付ファイルを含めることができますか?emailfile.eml
次のレイアウトで次のファイルを作成しています。
From: Company Name <[email protected]>
To: [email protected]
CC: [email protected]
Subject: Generated Output
Mime-Version: 1.0
This will be the body copy even though it's terrible
私は以下を使ってこのメールを送信しています。
# /usr/sbin/sendmail -t < emailfile.eml
これは作業中の文書ですが、この電子メールに添付ファイルを追加したいと思います。
答え1
他の人に役立つように、私に役立つソリューションを投稿しました。遅すぎてすみません。
私が見つけた最も信頼できる方法は、添付ファイルをemlファイル自体にbase64として含めることです。以下はemlコンテンツの例です。
注01:ファイルのbase64は、添付ファイルを引数としてLinuxでbase64コマンドを実行することによって生成されます(すべてのbase64ツールで機能する必要があります)。
注02:境界に使用される文字列は、日付とランダムな大文字を使用するごみです。
ファイル名: emlfile.eml
From: Sender <[email protected]>
To: [email protected]
CC: [email protected]
Disposition-Notification-To: [email protected]
Subject: Generic Subject
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="19032019ABCDE"
--19032019ABCDE
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Generic Body Copy
--19032019ABCDE
Content-Type: application;
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="MyPdfAttachment.pdf"
*base64 string goes here (no asterix)*
--19032019ABCDE--
その後、コマンドを使用してfilename.emlファイルを送信できます。これには添付ファイルが含まれます。
# /usr/sbin/sendmail -t < filename.eml
答え2
これにより、mutt
単に以下を使用できます。
echo "This is the message body" | mutt -a "/path/to/file_to_attach" -s "subject of message" -- [email protected]
使用mail
コマンド:
mail -a /opt/emailfile.eml -s "Email File" [email protected] < /dev/null
-a
添付ファイル用。
あなたはそれを使用することができますSendEmail
:
sendemail -t [email protected] -m "Here is the file." -a attachmentFile