電子メール本文とインラインで電子メール画像を添付する

電子メール本文とインラインで電子メール画像を添付する

現在、電子メールで添付ファイル(.png画像)を送信するスクリプトを使用しています。muttoptions と一緒にコマンドを使用するので、-a電子メールはメールの添付ファイルとして送信されます。

この.png画像をメール本文で送信したいと思います。この機能を実装するためにbashスクリプトをどのように使用できますか?

また、そのコマンドを試しましたが、mail結果は同じでした。これをPerlスクリプトで行うことができれば、これについての任意のアイデアを持ちたいと思います。

ベストアンサー1

デフォルトでは、muttはテキスト以外のすべての添付ファイルと画像をContent-Disposition:attachmentとしてマークします。 Content-Disposition:inlineを使用してこれを変更できます。

.muttrcを次のように設定します。

set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "

(%Iはインラインを意味し、他のオプションはドキュメントに記載されています。http://linux.die.net/man/5/muttrc)

または、この Perl スクリプトは次のように役立ちます。

 #!/usr/bin/perl -w
 use strict;
 use Mail::Sender;

 my $sender;

 ref ($sender = new Mail::Sender({from => 'you@xxxxxxxxxxx',
                                  smtp => 'your.smtp.server'})) 
        or die "$Mail::Sender::Error\n";

 ref ($sender->MailFile({to =>'address@xxxxxxxxxx',
                         msg=>"Here's your daily image\r\n\r\n", 
                         subject => 'Daily image',
                         file => 'image.gif',
                         disposition => 'inline'}))
        or die "$Mail::Sender::Error\n";

おすすめ記事