メール自動送信スクリプト
サークルの会場告知用に作成したスクリプトのメモ。前回のサークルで使ったスクリプトは英語例会だったので日本語対応させていなかったが、次回の例会用に日本語メールにも対応させた。スクリプトは以下のサイトを参考にさせて頂いた。
作成したスクリプトは以下
#!/usr/bin/perl # mail_send.pl # Usage: mail_send.pl [mail_file] # by aaa555 # $sendmail = "/usr/sbin/sendmail"; use Jcode; if($ARGV[0] eq ""){ printf "$0 [mail_file]\n" && die; } $mail_file = $ARGV[0]; open(SENDMAIL, "|$sendmail -t -i"); # Insert Content-type header print SENDMAIL "Content-type: text/plain;charset=\"ISO-2022-JP\"\n"; open(FILE,$mail_file); while(<FILE>){ $line = $_; &Jcode::convert(\$line,'jis'); if(/^To/ || /^From/ || /^Cc/ || /^Subject/){ $line = jcode($line)->mime_encode; } print SENDMAIL $line; } close(FILE); close(SENDMAIL);
I have a memo about a script for announcing a meeting place for our circle. The previous one couldn't handle Japanese. This one can handle Japanese mail.